Skip to content

Commit a33113c

Browse files
authoredMar 17, 2025
Tests: Add a CMake option to disable the main catch all exceptions (#2076)
- Add a CMake option to control the behavior of the main.cxx catch all exceptions - Use it in CI - Coverage reduction is expected and I believe a good idea to unsure this part of the code *is not* covered.
1 parent 0cb5da7 commit a33113c

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed
 

‎.github/actions/generic-ci/action.yml

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ runs:
209209
-DF3D_TESTING_ENABLE_GLX_TESTS=${{ (runner.os == 'Linux' && inputs.rendering_backend == 'auto') && 'ON' || 'OFF' }}
210210
-DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=${{ (runner.os == 'Linux' || runner.os == 'Windows') && 'ON' || 'OFF' }}
211211
-DF3D_TESTING_ENABLE_OSMESA_TESTS=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
212+
-DF3D_TESTING_DISABLE_CATCH_ALL=ON
212213
-DF3D_TESTING_FORCE_RENDERING_BACKEND=${{ inputs.rendering_backend }}
213214
-DF3D_WINDOWS_GUI=ON
214215
${{ runner.os == 'Windows' && '-Ax64 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL' || null }}

‎CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ cmake_dependent_option(F3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS "Enable long timeou
202202
cmake_dependent_option(F3D_TESTING_ENABLE_GLX_TESTS "Enable tests that require a X server running on Linux" ON "F3D_TESTING_ENABLE_RENDERING_TESTS AND UNIX AND NOT APPLE" OFF)
203203
cmake_dependent_option(F3D_TESTING_ENABLE_EGL_TESTS "Enable tests that require EGL to run" ON "F3D_TESTING_ENABLE_RENDERING_TESTS AND UNIX AND NOT APPLE" OFF)
204204
cmake_dependent_option(F3D_TESTING_ENABLE_OSMESA_TESTS "Enable tests that require OSMESA to run" ON "F3D_TESTING_ENABLE_RENDERING_TESTS AND UNIX AND NOT APPLE" OFF)
205+
cmake_dependent_option(F3D_TESTING_DISABLE_CATCH_ALL "Disable the catch all exception code in main for improved testing" OFF "BUILD_TESTING" OFF)
205206

206207
if(BUILD_TESTING)
207208
enable_testing()

‎application/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ if(F3D_STRICT_BUILD)
136136
endif()
137137
endif()
138138

139+
# F3D_TESTING_DISABLE_CATCH_ALL
140+
if (F3D_TESTING_DISABLE_CATCH_ALL)
141+
target_compile_definitions(f3d PRIVATE F3D_TESTING_DISABLE_CATCH_ALL)
142+
endif ()
143+
139144
# Coverage
140145
list(APPEND f3d_compile_options_public ${f3d_coverage_compile_options})
141146
list(APPEND f3d_link_options_public ${f3d_coverage_link_options})

‎application/main.cxx

+2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ int main(int argc, char** argv)
2222
// exit with error when needed
2323
exit(EXIT_FAILURE);
2424
}
25+
#ifndef F3D_TESTING_DISABLE_CATCH_ALL
2526
catch (const std::exception& ex)
2627
{
2728
f3d::log::error("F3D encountered an unexpected exception:");
2829
f3d::log::error(ex.what());
2930
exit(EXIT_FAILURE);
3031
}
32+
#endif
3133

3234
return res;
3335
}

0 commit comments

Comments
 (0)
Failed to load comments.