mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
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.
This commit is contained in:
parent
f8006aa6d4
commit
b7f4a2efb8
@ -40,6 +40,7 @@ set(_OverridableOptions
|
|||||||
"USE_ASYNC"
|
"USE_ASYNC"
|
||||||
"WCHAR"
|
"WCHAR"
|
||||||
"WINDOWS_SEH"
|
"WINDOWS_SEH"
|
||||||
|
"GETENV"
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(OptionName ${_OverridableOptions})
|
foreach(OptionName ${_OverridableOptions})
|
||||||
|
@ -155,13 +155,20 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`.
|
|||||||
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
||||||
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
||||||
CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter
|
CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter
|
||||||
|
CATCH_CONFIG_GETENV // System has a working `getenv`
|
||||||
|
|
||||||
> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch2 2.10.0
|
> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch2 2.10.0
|
||||||
|
|
||||||
|
> `CATCH_CONFIG_GETENV` was [introduced](https://github.com/catchorg/Catch2/pull/2562) in Catch2 X.Y.Z
|
||||||
|
|
||||||
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
||||||
|
|
||||||
`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`).
|
`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`).
|
||||||
|
|
||||||
|
`CATCH_CONFIG_GETENV` is on by default, except when Catch2 is compiled for
|
||||||
|
platforms that lacks working `std::getenv` (currently Windows UWP and
|
||||||
|
Playstation).
|
||||||
|
|
||||||
`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's
|
`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's
|
||||||
CRT is used to check for memory leaks, and displays them after the tests
|
CRT is used to check for memory leaks, and displays them after the tests
|
||||||
finish running. This option only works when linking against the default
|
finish running. This option only works when linking against the default
|
||||||
|
@ -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_USE_ASYNC
|
||||||
#cmakedefine CATCH_CONFIG_NO_USE_ASYNC
|
#cmakedefine CATCH_CONFIG_NO_USE_ASYNC
|
||||||
|
|
||||||
|
@ -118,19 +118,25 @@
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Assume that non-Windows platforms support posix signals by default
|
// We know some environments not to support full POSIX signals
|
||||||
#if !defined(CATCH_PLATFORM_WINDOWS)
|
#if defined( CATCH_PLATFORM_WINDOWS ) || \
|
||||||
#define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
|
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
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// We know some environments not to support full POSIX signals
|
// Assume that some platforms do not support getenv.
|
||||||
#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
|
#if defined(CATCH_PLATFORM_WINDOWS_UWP) || defined(CATCH_PLATFORM_PLAYSTATION)
|
||||||
#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
# define CATCH_INTERNAL_CONFIG_NO_GETENV
|
||||||
#endif
|
#else
|
||||||
|
# define CATCH_INTERNAL_CONFIG_GETENV
|
||||||
#ifdef __OS400__
|
|
||||||
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -273,6 +279,10 @@
|
|||||||
# define CATCH_CONFIG_POSIX_SIGNALS
|
# define CATCH_CONFIG_POSIX_SIGNALS
|
||||||
#endif
|
#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)
|
#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
|
# define CATCH_CONFIG_CPP11_TO_STRING
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,14 +7,16 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
#include <catch2/internal/catch_getenv.hpp>
|
#include <catch2/internal/catch_getenv.hpp>
|
||||||
|
|
||||||
#include <catch2/internal/catch_platform.hpp>
|
#include <catch2/internal/catch_platform.hpp>
|
||||||
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
#if defined( CATCH_PLATFORM_WINDOWS_UWP )
|
#if !defined (CATCH_CONFIG_GETENV)
|
||||||
char const* getEnv( char const* ) { return nullptr; }
|
char const* getEnv( char const* ) { return nullptr; }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -29,8 +31,7 @@ namespace Catch {
|
|||||||
# if defined( _MSC_VER )
|
# if defined( _MSC_VER )
|
||||||
# pragma warning( pop )
|
# pragma warning( pop )
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
# if defined( WINAPI_FAMILY ) && ( WINAPI_FAMILY == WINAPI_FAMILY_APP )
|
# if defined( WINAPI_FAMILY ) && ( WINAPI_FAMILY == WINAPI_FAMILY_APP )
|
||||||
# define CATCH_PLATFORM_WINDOWS_UWP
|
# define CATCH_PLATFORM_WINDOWS_UWP
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__ORBIS__) || defined(__PROSPERO__)
|
||||||
|
# define CATCH_PLATFORM_PLAYSTATION
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // CATCH_PLATFORM_HPP_INCLUDED
|
#endif // CATCH_PLATFORM_HPP_INCLUDED
|
||||||
|
@ -89,7 +89,7 @@ namespace Catch {
|
|||||||
TestCaseInfo const* rhs ) {
|
TestCaseInfo const* rhs ) {
|
||||||
return *lhs < *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 ) {
|
for ( auto const& test : tests ) {
|
||||||
const auto infoPtr = &test.getTestCaseInfo();
|
const auto infoPtr = &test.getTestCaseInfo();
|
||||||
const auto prev = seenTests.insert( infoPtr );
|
const auto prev = seenTests.insert( infoPtr );
|
||||||
|
@ -31,6 +31,8 @@ namespace Catch {
|
|||||||
std::tm timeInfo = {};
|
std::tm timeInfo = {};
|
||||||
#if defined (_MSC_VER) || defined (__MINGW32__)
|
#if defined (_MSC_VER) || defined (__MINGW32__)
|
||||||
gmtime_s(&timeInfo, &rawtime);
|
gmtime_s(&timeInfo, &rawtime);
|
||||||
|
#elif defined (CATCH_PLATFORM_PLAYSTATION)
|
||||||
|
gmtime_s(&rawtime, &timeInfo);
|
||||||
#else
|
#else
|
||||||
gmtime_r(&rawtime, &timeInfo);
|
gmtime_r(&rawtime, &timeInfo);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user