From 8c442491e3ca0cfe78dd57fa95b02ad5ae127610 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 13 Jan 2025 13:25:27 -0800 Subject: [PATCH] CTest: Define 42 as Skip Return Code Better than passing the test https://cmake.org/cmake/help/latest/prop_test/SKIP_RETURN_CODE.html --- examples/CMakeLists.txt | 2 ++ examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4ee39f675..93b429087 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -116,6 +116,8 @@ function(add_impactx_test name input is_mpi analysis_script plot_script) else() set_property(TEST ${name}.run APPEND PROPERTY ENVIRONMENT "OMP_NUM_THREADS=2") endif() + # special return code for skipped tests (e.g., runtime prerequisite fails) + set_tests_properties(${name}.run PROPERTIES SKIP_RETURN_CODE 42) # analysis and plots set(THIS_Python_SCRIPT_EXE) diff --git a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py index 5a9bb8bdb..85d62fbc2 100644 --- a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py +++ b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py @@ -37,7 +37,7 @@ print("Warning: Cannot import PyTorch. Skipping test.") import sys - sys.exit(0) + sys.exit(42) # ImpactX special return code for skipped tests import zipfile from urllib import request