Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-04-20 16:29:56 +0200
committerMartin Hořeňovský2024-04-21 21:52:33 +0200
commitefb39689d94e43132e4e48f01e676ae6a56d8df6 (patch)
treeb87ba2f5b4c30699e0868da58a943914f52ffd76 /tests
parent42fe78d0ba0eb33096a705e8f9c4814fd619eebd (diff)
downloadcatch3-efb39689d94e43132e4e48f01e676ae6a56d8df6.tar.gz
Add test for handleFatalErrorCondition within JUnit reporter
Diffstat (limited to 'tests')
-rw-r--r--tests/ExtraTests/CMakeLists.txt12
-rw-r--r--tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp32
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt
index 8eaf3a56..9f6d8173 100644
--- a/tests/ExtraTests/CMakeLists.txt
+++ b/tests/ExtraTests/CMakeLists.txt
@@ -467,6 +467,18 @@ set_tests_properties(
PASS_REGULAR_EXPRESSION "Errors occurred during startup!"
)
+add_executable(ReportingCrashWithJunitReporter ${TESTS_DIR}/X36-ReportingCrashWithJunitReporter.cpp)
+target_link_libraries(ReportingCrashWithJunitReporter PRIVATE Catch2::Catch2WithMain)
+add_test(
+ NAME Reporters::CrashInJunitReporter
+ COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:ReportingCrashWithJunitReporter> --reporter JUnit
+)
+set_tests_properties(
+ Reporters::CrashInJunitReporter
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "</testsuites>"
+ LABELS "uses-signals"
+)
add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated
X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp
diff --git a/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp b/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp
new file mode 100644
index 00000000..34f4cd85
--- /dev/null
+++ b/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp
@@ -0,0 +1,32 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+/**\file
+ * Checks that signals/SEH within open section does not hard crash JUnit
+ * (or similar reporter) while we are trying to report fatal error.
+ */
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <csignal>
+
+// On Windows we need to send SEH and not signal to test the
+// RunContext::handleFatalErrorCondition code path
+#if defined( _MSC_VER )
+# include <windows.h>
+#endif
+
+TEST_CASE( "raises signal" ) {
+ SECTION( "section" ) {
+#if defined( _MSC_VER )
+ RaiseException( 0xC0000005, 0, 0, NULL );
+#else
+ std::raise( SIGILL );
+#endif
+ }
+}