@@ -203,10 +203,17 @@ function(_add_test_with_options)
203203 ADDITIONAL_FIXTURE
204204 TOTAL_PROCS
205205 TIMEOUT
206+ SKIP
206207 INPUT_FILE
207208 OUTPUT_DIR
208209 )
209- set (multiValueArgs TEST_COMMAND REQUIRED_DEPENDENCIES LABELS CLEANUP_FIXTURES)
210+ set (multiValueArgs
211+ TEST_COMMAND
212+ REQUIRED_DEPENDENCIES
213+ LABELS
214+ EXCLUDE_PLATFORM
215+ CLEANUP_FIXTURES
216+ )
210217 cmake_parse_arguments (
211218 _parsed
212219 "${options} "
@@ -233,6 +240,10 @@ function(_add_test_with_options)
233240 set (_parsed_TOTAL_PROCS 1)
234241 endif ()
235242
243+ if (NOT DEFINED _parsed_SKIP)
244+ set (_parsed_SKIP "OFF" )
245+ endif ()
246+
236247 if (NOT DEFINED _parsed_TIMEOUT)
237248 set (_parsed_TIMEOUT "" )
238249 endif ()
@@ -252,6 +263,11 @@ function(_add_test_with_options)
252263 # check if all required dependencies are present
253264 check_required_dependencies (skip_message "${_parsed_REQUIRED_DEPENDENCIES} " )
254265
266+ # check if the test is marked to be skipped
267+ if (_parsed_SKIP STREQUAL "ON" )
268+ set (skip_message "The test ${_parsed_NAME_OF_TEST} is marked to be skipped" )
269+ endif ()
270+
255271 if (NOT skip_message STREQUAL "" )
256272 # The dummy test needs to report a arbitrary error code that ctest interprets as "skipped".
257273 set (dummy_command "echo \" ${skip_message} \" ; exit 42" )
@@ -321,6 +337,7 @@ endfunction()
321337# If multiple dependencies are provided, all must be met for the test to run.
322338# Note that the version is the _internal_ version that 4C assigns to the dependency.
323339# RETURN_AS: A variable name that allows to add further dependent tests based on this test.
340+ # EXCLUDE_PLATFORM: Mark to not run the test on specific platform.
324341function (four_c_test )
325342 set (options "" )
326343 set (oneValueArgs
@@ -330,7 +347,7 @@ function(four_c_test)
330347 OMP_THREADS
331348 RETURN_AS
332349 )
333- set (multiValueArgs LABELS REQUIRED_DEPENDENCIES)
350+ set (multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM )
334351 cmake_parse_arguments (
335352 _parsed
336353 "${options} "
@@ -397,6 +414,14 @@ function(four_c_test)
397414 math (EXPR _parsed_TIMEOUT "${FOUR_C_TEST_TIMEOUT_SCALE} * ${_parsed_TIMEOUT} " )
398415 endif ()
399416
417+ # check if the platform is matched
418+ # By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
419+ # then the test is ignored if the platform is matched.
420+ set (skip_var "OFF" )
421+ if (CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
422+ set (skip_var "ON" )
423+ endif ()
424+
400425 _add_test_with_options (
401426 NAME_OF_TEST
402427 ${name_of_test}
@@ -414,6 +439,8 @@ function(four_c_test)
414439 "${test_directory} "
415440 REQUIRED_DEPENDENCIES
416441 "${_parsed_REQUIRED_DEPENDENCIES} "
442+ SKIP
443+ "${skip_var} "
417444 )
418445endfunction ()
419446
@@ -433,6 +460,7 @@ endfunction()
433460# LABELS: Add labels to the test
434461# REQUIRED_DEPENDENCIES: Any required external dependencies. The test will be skipped if the dependencies are not met.
435462# RETURN_AS: A variable name that allows to add further dependent tests based on this test.
463+ # EXCLUDE_PLATFORM: Mark to not run the restart test on specific platform.
436464function (__four_c_test_restart )
437465 set (options SAME_FILE)
438466 set (oneValueArgs
@@ -445,7 +473,7 @@ function(__four_c_test_restart)
445473 RETURN_AS
446474 ASSERT_RESTART_STEP
447475 )
448- set (multiValueArgs LABELS REQUIRED_DEPENDENCIES)
476+ set (multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM )
449477 cmake_parse_arguments (
450478 _parsed
451479 "${options} "
@@ -533,6 +561,21 @@ function(__four_c_test_restart)
533561 )
534562 endif ()
535563
564+ # skip the restart test if the main test is skipped
565+ get_test_property (${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
566+ if (skip_code_base_var STREQUAL "NOTFOUND" )
567+ set (skip_var "OFF" )
568+ else ()
569+ set (skip_var "ON" )
570+ endif ()
571+
572+ # check if the platform is matched
573+ # By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
574+ # then the test is ignored if the platform is matched.
575+ if (CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
576+ set (skip_var "ON" )
577+ endif ()
578+
536579 check_test_exists (_base_test_exists ${_parsed_BASED_ON} )
537580 if (NOT _base_test_exists)
538581 message (FATAL_ERROR "Base test ${_parsed_BASED_ON} for restart does not exist." )
@@ -549,6 +592,8 @@ function(__four_c_test_restart)
549592 "${total_procs} "
550593 TIMEOUT
551594 "${_parsed_TIMEOUT} "
595+ SKIP
596+ "${skip_var} "
552597 LABELS
553598 "${_parsed_LABELS} "
554599 INPUT_FILE
@@ -602,6 +647,7 @@ endfunction()
602647# optional parameters:
603648# LABELS: add labels to the test
604649# REQUIRED_DEPENDENCIES: any required external dependencies. The test will be skipped if the dependencies are not met.
650+ # EXCLUDE_PLATFORM: mark to not run the test on specific platform.
605651#
606652function (__four_c_test_add_csv_yaml_comparison )
607653 set (options "" )
@@ -612,7 +658,7 @@ function(__four_c_test_add_csv_yaml_comparison)
612658 TOL_R
613659 TOL_A
614660 )
615- set (multiValueArgs LABELS REQUIRED_DEPENDENCIES)
661+ set (multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM )
616662 cmake_parse_arguments (
617663 _parsed
618664 "${options} "
@@ -642,6 +688,21 @@ function(__four_c_test_add_csv_yaml_comparison)
642688 "diff-with-tolerance ${test_directory} /${_parsed_RESULT_FILE} ${PROJECT_SOURCE_DIR } /tests/input_files/${_parsed_REFERENCE_FILE} ${_parsed_TOL_R} ${_parsed_TOL_A} "
643689 )
644690
691+ # skip the test if the main test is skipped
692+ get_test_property (${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
693+ if (skip_code_base_var STREQUAL "NOTFOUND" )
694+ set (skip_var "OFF" )
695+ else ()
696+ set (skip_var "ON" )
697+ endif ()
698+
699+ # check if the platform is matched
700+ # By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
701+ # then the test is ignored if the platform is matched.
702+ if (CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
703+ set (skip_var "ON" )
704+ endif ()
705+
645706 # Ensure that Python is listed as required dependency
646707 list (APPEND _parsed_REQUIRED_DEPENDENCIES "Python" )
647708 _add_test_with_options (
@@ -651,10 +712,14 @@ function(__four_c_test_add_csv_yaml_comparison)
651712 ${csv_comparison_command}
652713 ADDITIONAL_FIXTURE
653714 ${_parsed_BASED_ON}
715+ SKIP
716+ "${skip_var} "
654717 LABELS
655718 "${_parsed_LABELS} "
656719 REQUIRED_DEPENDENCIES
657720 "${_parsed_REQUIRED_DEPENDENCIES} "
721+ SKIP
722+ "${skip_var} "
658723 )
659724endfunction ()
660725
@@ -908,9 +973,10 @@ endfunction()
908973# The supported version constraint operators are: >=, <=, >, <, ==
909974# If multiple dependencies are provided, all must be met for the test to run.
910975# Note that the version is the _internal_ version that 4C assigns to the dependency.
976+ # EXCLUDE_PLATFORM: Mark to not run the test on specific platform.
911977function (four_c_test_tutorial )
912978 set (oneValueArgs TEST_FILE NP TIMEOUT)
913- set (multiValueArgs COPY_FILES REQUIRED_DEPENDENCIES)
979+ set (multiValueArgs COPY_FILES REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM )
914980 cmake_parse_arguments (
915981 _parsed
916982 "${options} "
@@ -964,6 +1030,13 @@ function(four_c_test_tutorial)
9641030 # check whether the dependencies are required
9651031 check_required_dependencies (skip_message "${_parsed_REQUIRED_DEPENDENCIES} " )
9661032
1033+ # check if the test is marked to be skipped
1034+ if (skip_message STREQUAL "" )
1035+ if (CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
1036+ set (skip_message "The test ${name_of_test} is marked to be skipped" )
1037+ endif ()
1038+ endif ()
1039+
9671040 if (NOT skip_message STREQUAL "" )
9681041 # The dummy test needs to report a arbitrary error code that ctest interprets as "skipped".
9691042 set (dummy_command "echo \" ${message} \" ; exit 42" )
@@ -1163,6 +1236,14 @@ function(__four_c_test_vtk)
11631236 # Ensure that Python is listed as required dependency
11641237 list (APPEND _parsed_REQUIRED_DEPENDENCIES "Python" )
11651238
1239+ # skip the test if the main test is skipped
1240+ get_test_property (${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
1241+ if (skip_code_base_var STREQUAL "NOTFOUND" )
1242+ set (skip_var "OFF" )
1243+ else ()
1244+ set (skip_var "ON" )
1245+ endif ()
1246+
11661247 # Add test
11671248 _add_test_with_options (
11681249 NAME_OF_TEST
@@ -1175,6 +1256,8 @@ function(__four_c_test_vtk)
11751256 "1"
11761257 TIMEOUT
11771258 "${_parsed_TIMEOUT} "
1259+ SKIP
1260+ "${skip_var} "
11781261 LABELS
11791262 "${_parsed_LABELS} "
11801263 OUTPUT_DIR
0 commit comments