diff options
| author | Masashi Fujita | 2022-11-09 22:47:55 +0900 |
|---|---|---|
| committer | GitHub | 2022-11-09 14:47:55 +0100 |
| commit | b7f4a2efb808e8d154874e168cec8e0aaf70bd06 (patch) | |
| tree | 3b58a5828a2799be853c6c81c34e57011665c283 /src | |
| parent | f8006aa6d41921ef0860da51206c4d958c167a0b (diff) | |
| download | catch3-b7f4a2efb808e8d154874e168cec8e0aaf70bd06.tar.gz | |
Add support for PlayStation platforms (#2562)
* Add new `CATCH_CONFIG` option for using `std::getenv`, because PS does not support env vars
* Add PS to platforms that have disabled posix signals.
* Small workaround for PS toolchain bug that prevents it from compiling `std::set` with lambda based comparator.
Diffstat (limited to 'src')
| -rw-r--r-- | src/catch2/catch_user_config.hpp.in | 10 | ||||
| -rw-r--r-- | src/catch2/internal/catch_compiler_capabilities.hpp | 30 | ||||
| -rw-r--r-- | src/catch2/internal/catch_getenv.cpp | 7 | ||||
| -rw-r--r-- | src/catch2/internal/catch_platform.hpp | 4 | ||||
| -rw-r--r-- | src/catch2/internal/catch_test_case_registry_impl.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.cpp | 2 |
6 files changed, 41 insertions, 14 deletions
diff --git a/src/catch2/catch_user_config.hpp.in b/src/catch2/catch_user_config.hpp.in index b6a0f191..3f6b10e8 100644 --- a/src/catch2/catch_user_config.hpp.in +++ b/src/catch2/catch_user_config.hpp.in @@ -130,6 +130,16 @@ +#cmakedefine CATCH_CONFIG_GETENV +#cmakedefine CATCH_CONFIG_NO_GETENV + +#if defined( CATCH_CONFIG_GETENV ) && \ + defined( CATCH_CONFIG_NO_GETENV ) +# error Cannot force GETENV to both ON and OFF +#endif + + + #cmakedefine CATCH_CONFIG_USE_ASYNC #cmakedefine CATCH_CONFIG_NO_USE_ASYNC diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 90e4cec3..f7cdb18b 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -118,19 +118,25 @@ //////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// // We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#if defined( CATCH_PLATFORM_WINDOWS ) || \ + defined( CATCH_PLATFORM_PLAYSTATION ) || \ + defined( __CYGWIN__ ) || \ + defined( __QNX__ ) || \ + defined( __EMSCRIPTEN__ ) || \ + defined( __DJGPP__ ) || \ + defined( __OS400__ ) +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#else +# define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS #endif -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +//////////////////////////////////////////////////////////////////////////////// +// Assume that some platforms do not support getenv. +#if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION) +# define CATCH_INTERNAL_CONFIG_NO_GETENV +#else +# define CATCH_INTERNAL_CONFIG_GETENV #endif //////////////////////////////////////////////////////////////////////////////// @@ -273,6 +279,10 @@ # define CATCH_CONFIG_POSIX_SIGNALS #endif +#if defined(CATCH_INTERNAL_CONFIG_GETENV) && !defined(CATCH_INTERNAL_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_NO_GETENV) && !defined(CATCH_CONFIG_GETENV) +# define CATCH_CONFIG_GETENV +#endif + #if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) # define CATCH_CONFIG_CPP11_TO_STRING #endif diff --git a/src/catch2/internal/catch_getenv.cpp b/src/catch2/internal/catch_getenv.cpp index da1c3922..a9a592c7 100644 --- a/src/catch2/internal/catch_getenv.cpp +++ b/src/catch2/internal/catch_getenv.cpp @@ -7,14 +7,16 @@ // SPDX-License-Identifier: BSL-1.0 #include <catch2/internal/catch_getenv.hpp> + #include <catch2/internal/catch_platform.hpp> +#include <catch2/internal/catch_compiler_capabilities.hpp> #include <cstdlib> namespace Catch { namespace Detail { -#if defined( CATCH_PLATFORM_WINDOWS_UWP ) +#if !defined (CATCH_CONFIG_GETENV) char const* getEnv( char const* ) { return nullptr; } #else @@ -29,8 +31,7 @@ namespace Catch { # if defined( _MSC_VER ) # pragma warning( pop ) # endif + } #endif - } - } // namespace Detail } // namespace Catch diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index 175b36a0..b11d9ccd 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -28,6 +28,10 @@ # if defined( WINAPI_FAMILY ) && ( WINAPI_FAMILY == WINAPI_FAMILY_APP ) # define CATCH_PLATFORM_WINDOWS_UWP # endif + +#elif defined(__ORBIS__) || defined(__PROSPERO__) +# define CATCH_PLATFORM_PLAYSTATION + #endif #endif // CATCH_PLATFORM_HPP_INCLUDED diff --git a/src/catch2/internal/catch_test_case_registry_impl.cpp b/src/catch2/internal/catch_test_case_registry_impl.cpp index b61fd661..4b3d2e47 100644 --- a/src/catch2/internal/catch_test_case_registry_impl.cpp +++ b/src/catch2/internal/catch_test_case_registry_impl.cpp @@ -89,7 +89,7 @@ namespace Catch { TestCaseInfo const* rhs ) { return *lhs < *rhs; }; - std::set<TestCaseInfo const*, decltype(testInfoCmp)> seenTests(testInfoCmp); + std::set<TestCaseInfo const*, decltype(testInfoCmp) &> seenTests(testInfoCmp); for ( auto const& test : tests ) { const auto infoPtr = &test.getTestCaseInfo(); const auto prev = seenTests.insert( infoPtr ); diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 6b31ad40..837d0489 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -31,6 +31,8 @@ namespace Catch { std::tm timeInfo = {}; #if defined (_MSC_VER) || defined (__MINGW32__) gmtime_s(&timeInfo, &rawtime); +#elif defined (CATCH_PLATFORM_PLAYSTATION) + gmtime_s(&rawtime, &timeInfo); #else gmtime_r(&rawtime, &timeInfo); #endif |