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

Enable testing via CTest #8737

Merged
merged 1 commit into from Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Expand Up @@ -283,6 +283,7 @@ if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLE
endif ()

if (protobuf_BUILD_TESTS)
enable_testing()
include(tests.cmake)
endif (protobuf_BUILD_TESTS)

Expand Down
8 changes: 6 additions & 2 deletions cmake/README.md
Expand Up @@ -164,7 +164,11 @@ Testing
To run unit-tests, first you must compile protobuf as described above.
Then run:

C:\Path\to\protobuf\cmake\build\release>nmake check
C:\Path\to\protobuf\cmake\build\release>ctest --progress --output-on-failure

You can also build the `check` target (not idiomatic CMake usage, though):

C:\Path\to\protobuf\cmake\build\release>cmake --build . --target check

or

Expand All @@ -183,7 +187,7 @@ You should see output similar to:
[==========] 1546 tests from 165 test cases ran. (2529 ms total)
[ PASSED ] 1546 tests.

To run specific tests:
To run specific tests, you need to pass some command line arguments to the test program itself:

C:\Path\to\protobuf>cmake\build\release\tests.exe --gtest_filter=AnyTest*
Running main() from gmock_main.cc
Expand Down
4 changes: 4 additions & 0 deletions cmake/tests.cmake
Expand Up @@ -254,3 +254,7 @@ add_custom_target(check
COMMAND tests
DEPENDS tests test_plugin
WORKING_DIRECTORY ${protobuf_source_dir})

add_test(NAME check
COMMAND tests
WORKING_DIRECTORY "${protobuf_source_dir}")