Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'--test' flag does not run the 'check' target? #66

Open
thoughton opened this issue Oct 13, 2018 · 1 comment
Open

'--test' flag does not run the 'check' target? #66

thoughton opened this issue Oct 13, 2018 · 1 comment

Comments

@thoughton
Copy link

thoughton commented Oct 13, 2018

Hi,

It's possible that I'm just misunderstanding the documentation here, but in the docs it says that using the --test flag on the build command wil make cget "try to run the check target" after building.

Does this mean that it will try to execute the resulting executable that is generated from building the check target? If so, this does not seem to happen.

Or am I misunderstanding and the docs mean something else by saying it will "run" the target?

Thanks!

@pfultz2
Copy link
Owner

pfultz2 commented Oct 25, 2018

Sorry for the late reply. I think maybe the documentation could be worded better. By running a target, it means it invokes the target with make check. It wont run the executables created, to do that you need to have check be a custom target that runs the executable, and then make the building of the executables dependent on the target.

Although with cmake you can run the test executables with add_test. And then have the check target run ctest:

add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})

For every executable you add you will need to make it dependent on the check target:

add_executable(main_test main.cpp)
add_dependencies(check main_test)

Alternatively, you can just add test executables to the main build when BUILD_TESTING=On and then do add_test to run them and cget will invoke ctest for you when using --test.

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

No branches or pull requests

2 participants