Skip to content

CTest #46

Closed
varunchennamadhava wants to merge 8 commits into
mainfrom
feat/ctest
Closed

CTest #46
varunchennamadhava wants to merge 8 commits into
mainfrom
feat/ctest

Conversation

@varunchennamadhava

Copy link
Copy Markdown
Collaborator

💡 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

Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Comment thread tests/CMakeLists.txt Outdated
Comment thread tests/CMakeLists.txt Outdated
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Comment thread CMakeLists.txt
include(CTest)

if(BUILD_TESTING)
add_subdirectory(tests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking online I see: add_dependencies() works on targets, not on tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/CMakeLists.txt Outdated
@@ -0,0 +1,273 @@
# =============================================================================
# CTest suite - translated from tests/test.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to delete the old test script.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will delete this right before PR merge.

Comment thread tests/CMakeLists.txt Outdated
Comment thread tests/CMakeLists.txt Outdated
Comment thread tests/CMakeLists.txt Outdated
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>
Signed-off-by: varunchennamadhava <varunchennamadhava@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants