From a12d1cfd67a076f0cecd2c0b955ee045b27b5989 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 12 Apr 2023 05:11:13 -0700 Subject: [PATCH] Fix test skipping logic for missing pytest module (#441) Signed-off-by: Scott K Logan --- ament_cmake_pytest/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ament_cmake_pytest/CMakeLists.txt b/ament_cmake_pytest/CMakeLists.txt index 2ff72286..77014c6d 100644 --- a/ament_cmake_pytest/CMakeLists.txt +++ b/ament_cmake_pytest/CMakeLists.txt @@ -20,6 +20,7 @@ if(BUILD_TESTING) # Check if pytest is available set(check_pytest_cmd "${python_interpreter}" "-m" "pytest" "--version") + set(SKIP_TEST_ARG "") execute_process( COMMAND ${check_pytest_cmd} RESULT_VARIABLE res @@ -30,7 +31,7 @@ if(BUILD_TESTING) "The Python module 'pytest' was not found, pytests cannot be run. " "On Linux, install the 'python3-pytest' package. " "On other platforms, install 'pytest' using pip.") - return() + set(SKIP_TEST_ARG SKIP_TEST) endif() set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/pytest.xunit.xml") @@ -51,6 +52,7 @@ if(BUILD_TESTING) COMMAND ${cmd} OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_cmake_pytest/pytest.txt" RESULT_FILE "${result_file}" + ${SKIP_TEST_ARG} ) set_tests_properties( pytest