Skip to content

Commit

Permalink
Report skipped tests in CTest output (#243)
Browse files Browse the repository at this point in the history
When adding a test using `ament_add_test`, the `SKIP_TEST` argument
results in the `--skip-test` argument being passed to the test wrapper
script `run_test.py`. The wrapper script then writes a JUnit output
describing that the test was skipped, and returns 0.

As far as CTest knows, the test succeeded and shows `Passed` on the
console. However, since we know that the test will be skipped by the
wrapper, and we expect the wrapper to return 0 after it writes the JUnit
file, we can set a test property that will mark the test as `Skipped`
when the wrapper returns 0.

This way, the JUnit output file is still written, but CTest displays the
test as skipped as well.

Signed-off-by: Scott K Logan <logans@cottsay.net>
  • Loading branch information
cottsay committed Apr 17, 2020
1 parent 40d2021 commit c67cdf2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ament_cmake_test/cmake/ament_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ function(ament_add_test testname)
"${testname}"
PROPERTIES TIMEOUT ${ARG_TIMEOUT}
)
if(ARG_SKIP_TEST)
set_tests_properties(
"${testname}"
PROPERTIES SKIP_RETURN_CODE 0
)
endif()
endfunction()

0 comments on commit c67cdf2

Please sign in to comment.