Skip to content

Commit efb3968

Browse files
committed
Add test for handleFatalErrorCondition within JUnit reporter
1 parent 42fe78d commit efb3968

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

tests/ExtraTests/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,18 @@ set_tests_properties(
467467
PASS_REGULAR_EXPRESSION "Errors occurred during startup!"
468468
)
469469

470+
add_executable(ReportingCrashWithJunitReporter ${TESTS_DIR}/X36-ReportingCrashWithJunitReporter.cpp)
471+
target_link_libraries(ReportingCrashWithJunitReporter PRIVATE Catch2::Catch2WithMain)
472+
add_test(
473+
NAME Reporters::CrashInJunitReporter
474+
COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:ReportingCrashWithJunitReporter> --reporter JUnit
475+
)
476+
set_tests_properties(
477+
Reporters::CrashInJunitReporter
478+
PROPERTIES
479+
PASS_REGULAR_EXPRESSION "</testsuites>"
480+
LABELS "uses-signals"
481+
)
470482

471483
add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated
472484
X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
// Copyright Catch2 Authors
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE.txt or copy at
5+
// https://www.boost.org/LICENSE_1_0.txt)
6+
7+
// SPDX-License-Identifier: BSL-1.0
8+
9+
/**\file
10+
* Checks that signals/SEH within open section does not hard crash JUnit
11+
* (or similar reporter) while we are trying to report fatal error.
12+
*/
13+
14+
#include <catch2/catch_test_macros.hpp>
15+
16+
#include <csignal>
17+
18+
// On Windows we need to send SEH and not signal to test the
19+
// RunContext::handleFatalErrorCondition code path
20+
#if defined( _MSC_VER )
21+
# include <windows.h>
22+
#endif
23+
24+
TEST_CASE( "raises signal" ) {
25+
SECTION( "section" ) {
26+
#if defined( _MSC_VER )
27+
RaiseException( 0xC0000005, 0, 0, NULL );
28+
#else
29+
std::raise( SIGILL );
30+
#endif
31+
}
32+
}

tools/misc/appveyorTestRunScript.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusion
55
cd Build
66
if "%CONFIGURATION%"=="Debug" (
77
if "%coverage%"=="1" (
8-
ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck || exit /b !ERRORLEVEL!
8+
ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck -LE uses-signals || exit /b !ERRORLEVEL!
99
python ..\tools\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL!
1010
codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL!
1111
) else (

0 commit comments

Comments
 (0)