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

cmake: Clean up testing code #1554

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jun 26, 2024

  1. Delete CTest module.

The CTest module handles CDash integration, which we do not use. It is not required for testing functionality.

  1. Clean up cases when to invoke enable_testing()

The enable_testing() command invocation is required for add_test() commands, which are used only for {noverify_}tests, exhaustive_tests and examples.

The `CTest` module handles `CDash` integration, which we do not use. It
is not required for testing functionality.
@real-or-random
Copy link
Contributor

The enable_testing() command invocation is required for add_test() commands, which are used only for {noverify_}tests, exhaustive_tests and examples.

I don't think it's required. It's just that add_test() has no effect without enable_testing().

enable_testing() seems cheap. Couldn't we just run it always? Or do you think this has drawbacks?

This change simplifies the code.
Also comments has been added to highlight the code structure.
@hebasto
Copy link
Member Author

hebasto commented Jun 27, 2024

The enable_testing() command invocation is required for add_test() commands, which are used only for {noverify_}tests, exhaustive_tests and examples.

I don't think it's required. It's just that add_test() has no effect without enable_testing().

enable_testing() seems cheap.

I agree.

Couldn't we just run it always?

Sure. The code has been adjusted.

Or do you think this has drawbacks?

I did some research and I haven't found any drawbacks. When enable_testing() is invoked and no tests being added, the created CTestTestfile.cmake files in the binary tree are noop/empty.

It is recommended:

to call enable_testing() somewhere in the top level CMakeLists.txt file. This would typically be done early, soon after the first project() call.

Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

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

utACK 7c987ec

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 7c987ec

I don't have too much knowledge about CMake, but following the discussion here and reading some CMake forum discussions (e.g. https://discourse.cmake.org/t/is-there-any-reason-to-prefer-include-ctest-or-enable-testing-over-the-other/1905/2), the simplification looks correct.

I did some research and I haven't found any drawbacks. When enable_testing() is invoked and no tests being added, the created CTestTestfile.cmake files in the binary tree are noop/empty.

Verified this by creating a fresh build directory via

$ rm -rf ./build && cmake -B build -DSECP256K1_BUILD_BENCHMARK=OFF -DSECP256K1_BUILD_TESTS=OFF -DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF -DSECP256K1_BUILD_CTIME_TESTS=OFF
$ cat ./build/src/CTestTestfile.cmake

and checking that the file only contains comment. If one of these options is ON, the file contains add_test(...) calls.

@real-or-random real-or-random merged commit 4c57c7a into bitcoin-core:master Sep 18, 2024
116 checks passed
@hebasto hebasto deleted the 240626-ctest-cleanup branch September 18, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants