Support the use of CTest launchers#109
Support the use of CTest launchers#109steve-downey merged 2 commits intobemanproject:mainfrom purpleKarrot:use-launchers
Conversation
|
@purpleKarrot , thanks for contributions inside the Beman Project! @bretbrownjr , can you please review this? |
|
I'm missing something in all of the CMake arcana. Bottom, line I wouldn't call myself opposed to this change, but it's hard to approve and merge without more documentation and education for Beman contributors. I really like the thought and expertise that went into this PR, though. So just to reiterate what I think is required of us. I think we should intentionally and cleanly support a test workflow. I don't think conditionally defining test hooks is the best way to do that. It's a lot cleaner to conditionally build tests but to unconditionally provide the hooks. Why? Because there's no standard and widely adopted mechanism or workflow to query a CMake project about whether there are tests or not. So it's best to let the user just run tests and let the xUnit results and CTest output convey the outcome of that action. As to the justification in a885d77, most users use the default As to As to the proposed commit, I have concerns about using For similar reasons (i.e., explaining surprising or important code), I have similar concerns about intentionally moving |
|
https://github.com/search?q=%22include%28CTestUseLaunchers%29%22&type=code shows 382 hits, many of which are forks of the same video project, or cmake itself or cmake docs. If it's useful, are we using it? |
|
@purpleKarrot Just checking in on this. I'm interested in this PR still. It sounds like you might have some ideas worth considering. We're looking for more explanation to proceed with this change. If it's easier to have a more interactive discussion, we have a Discourse that supports both forum posts and interactive chatting. Feel free to bring this up there. |
|
@purpleKarrot's rationale makes sense to me. The standard way to run tests in CMake projects is using the |
|
Hey @purpleKarrot, this PR was reviewed positively a couple of weeks ago. You should be able to merge it yourself but we can do it on your behalf if you like. |
This reverts commit a885d77. The rationale given in the original commit is not convincing. It assumes that users may be confused when a target called `test` is not unconditionally available. There are problems with that: 1. The recommended approach by CMake is to `include(CTest)`, which internally defines an option called `BUILD_TESTING` and then *conditionally* invokes `enable_testing()` based on this option. Hence, the fact that the test target is conditionally available is pretty standard. 2. The test target is called `test` for makefile generators only. It has a different name for IDE generators like VS and Xcode. That means `cmake --build build --target test` is not a portable way to execute the test target anyway. 3. Invoking tests with `cmake --build build --target test` is not a good recommendation to execute the tests, because there is no easy way to use parallelization. A better recommendation is `ctest -j $(nproc)`.
CMake recommends to `include(CTest)` in the top-level CMakeLists.txt. Including this module has the following side effects: * It defines an option called `BUILD_TESTING`. * It includes `CTestUseLaunchers`. * It invokes `enable_testing()` if `BUILD_TESTING` is ON. * It searches for version control systems and dynamic analysis checkers and defines a bunch of build targets for CI. If those additional build targets are not desired, a project may define its own condition on which it invokes `enable_testing()`. However, `CTestUseLaunchers` should always be included. Otherwise, setting `CTEST_USE_LAUNCHERS` in a CTest script results in the error message: ``` CMake Error: CTEST_USE_LAUNCHERS is enabled, but the RULE_LAUNCH_COMPILE global property is not defined. Did you forget to include(CTest) in the toplevel CMakeLists.txt ? ```
I see options to rebase and close, but no option to merge. Please do it or give me permission. |
Permission changes scare me more than merging. While we're sorting out the right bits, I'm hitting the "Merge pull request" button. |
This reverts commit a885d77.
The rationale given in the original commit is not convincing.
It assumes that users may be confused when a target called
testis not unconditionally available. There are two problemswith that:
The recommended approach by CMake is to
include(CTest), which internally defines an option calledBUILD_TESTINGand then conditionally invokesenable_testing()based on this option. Hence, the fact that the test target is conditionally available is pretty standard.The test target is called
testfor makefile generators only. It has a different name for IDE generators like VS and Xcode. That meanscmake --build build --target testis not a portable way to execute the test target anyway.CMake recommends to
include(CTest)in the top-level CMakeLists.txt.Including this module has the following side effects:
BUILD_TESTING.CTestUseLaunchers.enable_testing()ifBUILD_TESTINGis ON.If those additional build targets are not desired, a project may define its own condition on which it invokes
enable_testing().However,
CTestUseLaunchersshould always be included. Otherwise, settingCTEST_USE_LAUNCHERSin a CTest script results in the error message: