diff --git a/test/default_handler_tests.cpp b/test/default_handler_tests.cpp index b4172bf..b018d03 100644 --- a/test/default_handler_tests.cpp +++ b/test/default_handler_tests.cpp @@ -6,14 +6,32 @@ ADOBE_DEFAULT_CONTRACT_VIOLATION_HANDLER() -#if defined(GTEST_OS_WINDOWS) || defined(__EMSCRIPTEN__) +#if defined(__EMSCRIPTEN__) + +// GoogleTest doesn't support death tests under emscripten, so instead +// we handle death by setting the test's WILL_FAIL property in CMake. +// Therefore the test simply executes the code that aborts with no +// wrapper. There's currently no facility for checking test output. + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define EXPECT_ABORT(code, expected_output_regex) code + +#elif defined(GTEST_OS_WINDOWS) +// GoogleTest doesn't support checking for the abort signal on +// Windows, so we use an auxilliary file, win32_abort_detection.cpp, +// to ensure that an unusual string is printed, which we can check for +// with the EXPECT_DEATH macro. + // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define EXPECT_ABORT(code, expected_output_regex) \ - EXPECT_DEATH_IF_SUPPORTED(code, expected_output_regex ".*\n*##ABORTED##"); + EXPECT_DEATH(code, expected_output_regex ".*\n*##ABORTED##"); + #else + // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define EXPECT_ABORT(code, expected_output_regex) \ EXPECT_EXIT(code, testing::KilledBySignal(SIGABRT), expected_output_regex); + #endif TEST(DefaultHandler, ContractNonViolationsDoNotCauseAbort)