Skip to content

Commit

Permalink
Call enable_testing() in top-level project
Browse files Browse the repository at this point in the history
Per CMake documentation, this should be called in the top-level
CMakeLists.txt so that testing is enabled for the _project_, and not a
subdirectory thereof. This will allow tools like colcon to discover the
tests.
  • Loading branch information
cottsay committed Oct 9, 2024
1 parent 1121fea commit aa503c5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
ctest --build-config ${{ matrix.build_type }} --no-tests=error --output-on-failure --verbose --test-dir test/
ctest --build-config ${{ matrix.build_type }} --no-tests=error --output-on-failure --verbose
- name: Test Python Module Import
working-directory: ${{ steps.strings.outputs.build-output-dir }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ jobs:
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target install

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
ctest --no-tests=error --output-on-failure --verbose
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,6 @@ if (BUILD_EXAMPLES)
endif()

if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enable_testing()

add_library(getline OBJECT getline.c)

add_executable(test_detection test_detection.c)
Expand Down

0 comments on commit aa503c5

Please sign in to comment.