Skip to content

Commit d09de49

Browse files
kodiakhq[bot]jngrad
authored andcommitted
Address API change in Python 3.12 unittest module (#4852)
Starting with Python 3.12, package `unittest` returns exit code 5 when all tests are skipped. By default, CTest treats any non-zero exit code as a failure. This can be remediated by setting test property [`SKIP_RETURN_CODE`](https://cmake.org/cmake/help/latest/prop_test/SKIP_RETURN_CODE.html) to 5. Description of changes: - skipped tests are no longer treated as failures by CTest
1 parent 7525b50 commit d09de49

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

testsuite/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function(PYTHON_TEST)
5757
endif()
5858
set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${TEST_NUM_PROC}
5959
DEPENDS "${TEST_DEPENDS}")
60+
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_RETURN_CODE 5)
6061

6162
if("gpu" IN_LIST TEST_LABELS AND WITH_CUDA)
6263
set_tests_properties(${TEST_NAME} PROPERTIES RESOURCE_LOCK GPU)

testsuite/scripts/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ macro(PYTHON_SCRIPTS_TEST)
3939
string(REGEX REPLACE "^test_" "${TEST_TYPE}_" TEST_NAME ${TEST_NAME})
4040
add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/pypresso ${PYPRESSO_OPTIONS}
4141
${TEST_FILE_CONFIGURED})
42+
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_RETURN_CODE 5)
4243
set_tests_properties(${TEST_NAME} PROPERTIES FIXTURES_REQUIRED
4344
IMPORTLIB_WRAPPER)
4445
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "${TEST_LABELS}")

testsuite/scripts/benchmarks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ endfunction(BENCHMARK_TEST)
2525
# configure Python module importlib_wrapper.py
2626
add_test(importlib_wrapper ${CMAKE_BINARY_DIR}/pypresso ${PYPRESSO_OPTIONS}
2727
${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER})
28+
set_tests_properties(importlib_wrapper PROPERTIES SKIP_RETURN_CODE 5)
2829
set_tests_properties(importlib_wrapper PROPERTIES FIXTURES_SETUP
2930
IMPORTLIB_WRAPPER)
3031
set(benchmarks_tests ${benchmarks_tests}

testsuite/scripts/samples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ endfunction(SAMPLE_TEST)
2525
# configure Python module importlib_wrapper.py
2626
add_test(importlib_wrapper ${CMAKE_BINARY_DIR}/pypresso ${PYPRESSO_OPTIONS}
2727
${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER})
28+
set_tests_properties(importlib_wrapper PROPERTIES SKIP_RETURN_CODE 5)
2829
set_tests_properties(importlib_wrapper PROPERTIES FIXTURES_SETUP
2930
IMPORTLIB_WRAPPER)
3031
set(samples_tests ${samples_tests} ${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER}

testsuite/scripts/tutorials/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ add_test(importlib_wrapper ${CMAKE_BINARY_DIR}/pypresso ${PYPRESSO_OPTIONS}
2828
${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER})
2929
add_test(convert ${CMAKE_BINARY_DIR}/pypresso ${PYPRESSO_OPTIONS}
3030
${CMAKE_CURRENT_BINARY_DIR}/test_convert.py)
31+
set_tests_properties(importlib_wrapper PROPERTIES SKIP_RETURN_CODE 5)
3132
set_tests_properties(importlib_wrapper PROPERTIES FIXTURES_SETUP
3233
IMPORTLIB_WRAPPER)
34+
set_tests_properties(convert PROPERTIES SKIP_RETURN_CODE 5)
3335
set_tests_properties(convert PROPERTIES FIXTURES_SETUP IMPORTLIB_WRAPPER)
3436
set(tutorials_tests ${tutorials_tests} ${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER}
3537
PARENT_SCOPE)

0 commit comments

Comments
 (0)