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

Add cmake Modules for boosttest_discover_tests #7

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

DenizThatMenace
Copy link

I created a CMake script module which implements a boosttest_discover_tests CMake function, similar to the one provided by CMake for GTest.

It also implements the new PRE_TESTbehavior that exists for GTest which will be released with the next CMake release (3.18).

@pdimov
Copy link
Member

pdimov commented May 22, 2020

I'm not sure how this is going to work. How are people going to use these modules? They aren't going to be shipped with the Boost.Test package as installed by apt install libboost-test for instance.

Ideally, after find_package(Boost REQUIRED unit_test_framework), the modules would become available, somehow. But we currently have no mechanism of achieving this.

@DenizThatMenace
Copy link
Author

Ultimately they should probably somehow be installed together with Boost.Test.

But for now they would be in the Boost-source package and need to be copied by hand.

@DenizThatMenace
Copy link
Author

DenizThatMenace commented May 24, 2020

I just fixed some small errors.

Add a new CMake module `BoostTestDiscoverTests` which provides a
function `boosttest_discover_tests`.

This function `boosttest_discover_tests` is similar to the function
`gtest_discover_tests` provided by the `GoogleTest` module (which comes
with CMake).

It can discover all the tests from an executable target that was built
with the Unit-Test-Framework from Boost.Test and creates individual
test-targets for each of it. When running these tests using CTest each
test will get an individual success or failure entry in CTest's output.

This function `boosttest_discover_tests` provides two different modes
for discovering tests: `POST_BUILD`, which discovers the tests at
build-time, and `PRE_TEST`, which discovers the tests at run-time.
(The later mode is more flexible and also better supports
cross-compilation scenarios.)

For more information read the documentation contained in the module
`BoostTestDiscoverTests.cmake`.
In case the test executable does not contain any discoverable tests
(that use Boost.Test) a dummy test-target will be registered which is
disabled and whose name should indicate that tests are missing.
@DenizThatMenace
Copy link
Author

I rewrote the original implementation and made it compatible with older CMake versions.

This boosttest_discover_tests implementation was inspired by the gtest_discover_tests implementation for GoogleTest that comes with CMake.
I reached out to the original authors and contributors of gtest_discover_tests and asked them to dual-license their work also under the Boost Software License. They kindly agreed!
Therefore I now got permission to distribute the implementation of boosttest_discover_tests under the Boost Software License as well.

So, at least the license should not be a problem to integrate it with Boost.


@pdimov Regarding your question how these modules can be used by users of Boost.Test:

  1. I think the first step would be to just distribute these files together with the Boost source releases. (As I already said, interested users could just grab and copy these files into their own project.) That is mainly done by this pull-request.

  2. As a second step it should not be too difficult to make them available while building Boost using the new approach that uses CMake directly. (It is pretty much just a list(APPEND CMAKE_MODULE_PATH "<path-to-this-Module-dir>") call.)

  3. As a last step we should figure out a mechanism for installing these files together with the import-configuration files of Boost.Test. I do not think that will be too difficult.
    From CMake that is just a simple install(FILES...) command (that should be associated with the Boost.Test component. (And I am sure that b2 can do something similar.)
    And when the import-configuration of Boost.Test is getting loaded by the user, that configuration just needs to provide a variable/property that should point to the directory containing these files. This directory then only has to be added to CMAKE_MODULE_PATH and the user has access to these files.

@ficzerepeti
Copy link

Hi, I've come here to add my upvote to get this functionality included.
Similar approach could be taken to get these files discovered as for Catch2.
Is there more to this that I'm not seeing? I'm happy to help in case further work is needed.

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.

3 participants