Skip to content

Commit

Permalink
Fix test skipping logic for missing pytest module (ament#441)
Browse files Browse the repository at this point in the history
Signed-off-by: Scott K Logan <logans@cottsay.net>
  • Loading branch information
cottsay authored and ejalaa12 committed Nov 8, 2023
1 parent dc9140a commit a345a1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ament_cmake_pytest/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit a345a1f

Please sign in to comment.