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 module to discover tests #112

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

Conversation

bracketttc
Copy link

Adapted shamelessly from the official Google Test module distributed
with CMake 3.9 and higher.

Adapted shamelessly from the official Google Test module distributed
with CMake 3.9 and higher.
@bracketttc
Copy link
Author

  • Add to README.md

@silentbicycle
Copy link
Owner

Rather than scanning the test source, it might be more reliable to use the test runner's -l flag, which lists the suite and test case names in a consistent and easily scraped format. That does require building and executing the program, but it doesn't actually run any of the tests.

It would probably be good to check if running the same test case in a loop with different arguments (such as gradually increasing bounds) is handled well. greatest_set_test_suffix can be used to add a parameter suffix to the test case names, which would otherwise be the same each time.

(Also, is "adapting shamelessly" okay with the Google Test module's licensing?)

I don't see anything problematic here, but I don't know CMake very well enough to review the code in depth.

@bracketttc
Copy link
Author

The GoogleTest module has functions for both, so that shouldn't be hard. Not 100% sure why I only took one of the functions except that it does what I want and the other sometimes has issues with static initialization (if you write test executables with static initialization that can fail, your build system can fail).

CMake's modules are under BSD 3 clause, so I think it's cool to lift, but should probably reproduce the license in this module as well.

https://github.com/Kitware/CMake/blob/460e812369db398da34e14c9d40c3ecec06afaf1/Modules/GoogleTest.cmake

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.

2 participants