CTest #46
Conversation
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
| include(CTest) | ||
|
|
||
| if(BUILD_TESTING) | ||
| add_subdirectory(tests) |
There was a problem hiding this comment.
Is there a way to get CTest to depend on libcbxp and cbxp like the old custom target?
The issue is that I would expect that running cmake . and then CTest, would ensure that libcbxp and cbxp are built before running the tests, but it doesn't and the tests all just fail.
Also, I think you should only need to specify that the tests depend on cbxp. libcbxp is a dependency of cbxpalready so there should be be no need to specify libcbxp as a dependency.
I think you might be able to use add_dependencies(): https://cmake.org/cmake/help/latest/command/add_dependencies.html
Something like this maybe:
add_test(NAME ${name} COMMAND ${ARGN})
set_property(TEST ${name} PROPERTY WILL_FAIL TRUE)
add_dependencies(my_test ${name} cbxp)There was a problem hiding this comment.
Looking online I see: add_dependencies() works on targets, not on tests.
There was a problem hiding this comment.
The fix I went with is a CTest fixture. A special cbxp.build test is registered with FIXTURES_SETUP, whose only job is to run cmake --build --target cbxp. Every real test then declares FIXTURES_REQUIRED on that fixture, so CTest guarantees the build step runs and succeeds first. If the build fails, the dependent tests are skipped cleanly rather than crashing with a missing binary.
| @@ -0,0 +1,273 @@ | |||
| # ============================================================================= | |||
| # CTest suite - translated from tests/test.sh | |||
There was a problem hiding this comment.
Make sure to delete the old test script.
There was a problem hiding this comment.
will delete this right before PR merge.
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
8acd8e0 to
5284d45
Compare
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
💡 Issue Reference
Issue: Include any issues related to this PR
💻 What does this address?
Details of the issue...why is this necessary?
📟 Implementation Details
How was this feature/issue implemented?
📋 Is there a test case?
Include the details of the tests that were done