Repository navigation
cmake: support default build and test workflow - #204
purpleKarrot wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
Code review 47deaef. Thanks for the PR. These changes seem worth considering, and it does seem pretty indefensible that "make test" doesn't build the tests it depends on. This behavior seems to be a longstanding bug or quirk of cmake, and it's especially surprising given how cmake's "make test" target works differently than its "make install" target when it comes to building dependencies. I think it could be good to implement the "fixtures" idea in the linked stackoverflow thread to address this, but not good to build targets by default that aren't needed for installation. I think it's best for the 'make; make install` workflow to be fast and reliable and not do unnecessary work. I'm also not sure about the other part of this change removing convenience targets. |
|
CI fails: |
Make sure that the default workflow of `cmake ..; make; make test` does not fail with an error message that no tests are found. Remove any "convenience" targets that add maintenance burden and require tribal knowledge.
47deaef to
1674fe0
Compare
|
Thanks for the review, @ryanofsky.
Stackoverflow is not a good source of information when it comes to CMake (neither is chatgpt, which seems to be trained on content from stackoverflow as well as projects that followed the advices found there). Too often, the accepted answers are outdated or plain wrong. In this particular case, what you are looking for is
This is exactly my concern. The project configuration is intertwined with CI scripts. What I aim for, is that projects and CI scripts are developed independently against a defined interface so that CI scripts can be reused for multiple projects. About
|
I'd be very interested in this. If there's a generic cmake CI framework that could be plugged in here to simply the CI configuration here that would be great. Absent that though, I think
Yeah that part makes sense. But it would also make sense if cmake provided a way to control what test target depends on, using something like |
|
I think my main objection to this is I don't think the "configure, make, make install" should be doing unnecessary work and building things that don't get installed or used. I do think the "configure, make, make test" workflow should work, though and I appreciate you pointing out that it is broken. If there's a way to fix this without using "make check", which it seems like there might be, I do think we can drop "make check" |
|
There hasn't been much activity lately. What is the status here? Finding reviewers may take time. However, if the patch is no longer relevant, please close this pull request. If the author lost interest or time to work on this, please close it and mark it with one of the labels 'Up for grabs' or 'Insufficient Review', so that it can be picked up in the future. |
There was a problem hiding this comment.
ACK 1674fe0.
Remove any "convenience" targets that add maintenance burden and require tribal knowledge.
I agree with that.
I think my main objection to this is I don't think the "configure, make, make install" should be doing unnecessary work and building things that don't get installed or used.
That workflow is still available with this PR:
$ cmake .. -DBUILD_TESTING=OFF && make && make install
ryanofsky
left a comment
There was a problem hiding this comment.
re: #204 (review)
Code review 1674fe0. Thanks for following up on this. I agree cmake ..; make; make test should work and that it's good to drop the custom tests and check targets, but I think both can be done without building tests by default, which I'd prefer.
That workflow is still available with this PR:
cmake .. -DBUILD_TESTING=OFF && make && make install
It is available, but I think defaults should be chosen for users building and installing the library, who shouldn't need to know about -DBUILD_TESTING=OFF. For example, Bitcoin Core's depends system runs plain cmake . and make to build libmultiprocess. I checked, and with this PR the depends build compiles mptest, which nothing runs.
Instead of removing EXCLUDE_FROM_ALL from the test directory, a CTest fixture in test/CMakeLists.txt could build mptest before running it:
if(MP_STANDALONE)
add_test(NAME mptest-build COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --config $<CONFIG> --target mptest)
set_tests_properties(mptest-build PROPERTIES FIXTURES_SETUP mptest-build)
set_tests_properties(mptest PROPERTIES FIXTURES_REQUIRED mptest-build)
endif()I tried this on top of the current PR branch with add_subdirectory(test EXCLUDE_FROM_ALL) restored. make and make install don't build mptest, and make test, ctest -R mptest and ninja test build it and run it. The depends build doesn't build mptest, and the MP_STANDALONE check keeps the extra test out of Bitcoin Core's ctest. Other projects use the same approach, for example lastpass-cli and c-vector.
Remove any "convenience" targets that add maintenance burden and require tribal knowledge.
I agree with that.
I agree the core build shouldn't be complicated by targets like these, and with the fixture tests and check aren't needed. But I don't think convenience targets are a problem in themselves if they're kept separate from what's needed to build and install the library. In #314 (comment) I sketched an MP_EXTRAS option that moves clang-tidy and IWYU support out of the main CMakeLists.txt into a cmake/extras.cmake file that is only included when requested. Something like that could hold targets like these if they turn out to be useful again.
Separately, since this removes the check target, the make check line in doc/install.md should change, to something like make test # Optionally build and run tests.
Would the fixture approach work for you both?
This approach would still conflict with my vision of a separation of responsibilities between project maintainers and build pipeline maintainers. The consequences of the current approach are already visible on my dashboard, where tests fail because the executable does not exist. Moving compilation into a CTest fixture would solve that particular problem but bypass When I say "don't try to be smart", I mean it. Every workaround/hack breaks something else. The intervention spiral hitting again. |
Make sure that the default workflow of
cmake ..; make; make testdoes not fail with an error message that no tests are found.Remove any "convenience" targets that add maintenance burden and require tribal knowledge.