diff options
author | Ashish Sadanandan <ashish.sadanandan@gmail.com> | 2021-07-26 16:44:21 (GMT) |
---|---|---|
committer | Ashish Sadanandan <ashish.sadanandan@gmail.com> | 2021-08-05 06:43:17 (GMT) |
commit | ea6a7dd1c2e76533d6aa4725e04acc3d8e1ed912 (patch) | |
tree | 727cb24ff45ab42d2a00ce5aeab016363a25c327 /Tests/RunCMake/GoogleTest/fake_gtest.cpp | |
parent | 6c0f476505166c3aed414c7707b92c68e278f9b3 (diff) | |
download | CMake-ea6a7dd1c2e76533d6aa4725e04acc3d8e1ed912.zip CMake-ea6a7dd1c2e76533d6aa4725e04acc3d8e1ed912.tar.gz CMake-ea6a7dd1c2e76533d6aa4725e04acc3d8e1ed912.tar.bz2 |
GoogleTest: Add TEST_FILTER arg to gtest_discover_tests
The `TEST_FILTER` argument can be used to filter tests during the
discovery phase. It combines `--gtest_filter=<expr>` with the
`--gtest_list_tests` argument when invoking the test excutable for
listing defined tests.
Fixes: #17493
Diffstat (limited to 'Tests/RunCMake/GoogleTest/fake_gtest.cpp')
-rw-r--r-- | Tests/RunCMake/GoogleTest/fake_gtest.cpp | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp index 1956c37..b2a5cb4 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -7,27 +7,42 @@ int main(int argc, char** argv) // it only requires that we produces output in the expected format when // invoked with --gtest_list_tests. Thus, we fake that here. This allows us // to test the module without actually needing Google Test. + bool is_filtered = + argc > 2 && std::string(argv[2]).find("--gtest_filter=") == 0; + bool is_basic_only = + is_filtered && std::string(argv[2]).find("basic*") != std::string::npos; + bool is_typed_only = + is_filtered && std::string(argv[2]).find("typed*") != std::string::npos; + if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { - std::cout << "basic." << std::endl; - std::cout << " case_foo" << std::endl; - std::cout << " case_bar" << std::endl; - std::cout << " DISABLED_disabled_case" << std::endl; - std::cout << " DISABLEDnot_really_case" << std::endl; - std::cout << "DISABLED_disabled." << std::endl; - std::cout << " case" << std::endl; - std::cout << "DISABLEDnotreally." << std::endl; - std::cout << " case" << std::endl; - std::cout << "typed/0. # TypeParam = short" << std::endl; - std::cout << " case" << std::endl; - std::cout << "typed/1. # TypeParam = float" << std::endl; - std::cout << " case" << std::endl; - std::cout << "value/test." << std::endl; - std::cout << " case/0 # GetParam() = 1" << std::endl; - std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; - std::cout << "param/special." << std::endl; - std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; - std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; - std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; + if (!is_typed_only) { + std::cout << "basic." << std::endl; + std::cout << " case_foo" << std::endl; + std::cout << " case_bar" << std::endl; + std::cout << " DISABLED_disabled_case" << std::endl; + std::cout << " DISABLEDnot_really_case" << std::endl; + } + if (!is_basic_only && !is_typed_only) { + std::cout << "DISABLED_disabled." << std::endl; + std::cout << " case" << std::endl; + std::cout << "DISABLEDnotreally." << std::endl; + std::cout << " case" << std::endl; + } + if (!is_basic_only) { + std::cout << "typed/0. # TypeParam = short" << std::endl; + std::cout << " case" << std::endl; + std::cout << "typed/1. # TypeParam = float" << std::endl; + std::cout << " case" << std::endl; + } + if (!is_basic_only && !is_typed_only) { + std::cout << "value/test." << std::endl; + std::cout << " case/0 # GetParam() = 1" << std::endl; + std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; + std::cout << "param/special." << std::endl; + std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; + std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; + std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; + } return 0; } |