mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +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
|
# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PS4
|
||||||
|
#if defined(__ORBIS__)
|
||||||
|
# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Cygwin
|
// Cygwin
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
@ -165,6 +171,13 @@
|
|||||||
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||||
#endif
|
#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)
|
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
|
||||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
||||||
|
@ -15,15 +15,18 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
#include <io.h> //_dup and _dup2
|
#if defined(_MSC_VER)
|
||||||
#define dup _dup
|
#include <io.h> //_dup and _dup2
|
||||||
#define dup2 _dup2
|
#define dup _dup
|
||||||
#define fileno _fileno
|
#define dup2 _dup2
|
||||||
#else
|
#define fileno _fileno
|
||||||
#include <unistd.h> // dup and dup2
|
#else
|
||||||
|
#include <unistd.h> // dup and dup2
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream )
|
RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream )
|
||||||
@ -48,6 +51,7 @@ namespace Catch {
|
|||||||
auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
|
auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
TempFile::TempFile() {
|
TempFile::TempFile() {
|
||||||
@ -122,11 +126,14 @@ namespace Catch {
|
|||||||
m_stderrDest += m_stderrFile.getContents();
|
m_stderrDest += m_stderrFile.getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CATCH_CONFIG_NEW_CAPTURE
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
#undef dup
|
#if defined(_MSC_VER)
|
||||||
#undef dup2
|
#undef dup
|
||||||
#undef fileno
|
#undef dup2
|
||||||
|
#undef fileno
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,6 +47,8 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
|
|
||||||
// Windows's implementation of std::tmpfile is terrible (it tries
|
// Windows's implementation of std::tmpfile is terrible (it tries
|
||||||
// to create a file inside system folder, thus requiring elevated
|
// to create a file inside system folder, thus requiring elevated
|
||||||
// privileges for the binary), so we have to use tmpnam(_s) and
|
// privileges for the binary), so we have to use tmpnam(_s) and
|
||||||
@ -92,6 +94,7 @@ namespace Catch {
|
|||||||
std::string& m_stderrDest;
|
std::string& m_stderrDest;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user