mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Allow disabling the implementation of the new output capture
As it turns out, some platforms do not provide things like `dup`, or `std::tmpfile`, but they do provide streams... Closes #1335 Related to #1311
This commit is contained in:
parent
76790604f5
commit
9ee4c1db52
@ -95,6 +95,12 @@
|
||||
# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// PS4
|
||||
#if defined(__ORBIS__)
|
||||
# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Cygwin
|
||||
#ifdef __CYGWIN__
|
||||
@ -165,6 +171,13 @@
|
||||
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
||||
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||
# define CATCH_CONFIG_NEW_CAPTURE
|
||||
#endif
|
||||
|
||||
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
|
||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
||||
|
@ -15,15 +15,18 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <io.h> //_dup and _dup2
|
||||
#define dup _dup
|
||||
#define dup2 _dup2
|
||||
#define fileno _fileno
|
||||
#else
|
||||
#include <unistd.h> // dup and dup2
|
||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||
#if defined(_MSC_VER)
|
||||
#include <io.h> //_dup and _dup2
|
||||
#define dup _dup
|
||||
#define dup2 _dup2
|
||||
#define fileno _fileno
|
||||
#else
|
||||
#include <unistd.h> // dup and dup2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Catch {
|
||||
|
||||
RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream )
|
||||
@ -48,6 +51,7 @@ namespace Catch {
|
||||
auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
|
||||
|
||||
|
||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
TempFile::TempFile() {
|
||||
@ -122,11 +126,14 @@ namespace Catch {
|
||||
m_stderrDest += m_stderrFile.getContents();
|
||||
}
|
||||
|
||||
#endif // CATCH_CONFIG_NEW_CAPTURE
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef fileno
|
||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||
#if defined(_MSC_VER)
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef fileno
|
||||
#endif
|
||||
#endif
|
||||
|
@ -47,6 +47,8 @@ namespace Catch {
|
||||
};
|
||||
|
||||
|
||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||
|
||||
// Windows's implementation of std::tmpfile is terrible (it tries
|
||||
// to create a file inside system folder, thus requiring elevated
|
||||
// privileges for the binary), so we have to use tmpnam(_s) and
|
||||
@ -92,6 +94,7 @@ namespace Catch {
|
||||
std::string& m_stderrDest;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user