summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Shcherbina <ixsci@pm.me>2022-02-04 10:03:30 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-07 17:53:16 (GMT)
commitf28f738bd2be2ed790bb5b4c794773b7a627d3f2 (patch)
treef340702240d59653a59cfec97fe0873a4cc6c12c
parentc8a955584d5edeb426a0176da1847c84c3b99e89 (diff)
downloadCMake-f28f738bd2be2ed790bb5b4c794773b7a627d3f2.zip
CMake-f28f738bd2be2ed790bb5b4c794773b7a627d3f2.tar.gz
CMake-f28f738bd2be2ed790bb5b4c794773b7a627d3f2.tar.bz2
GoogleTest: Fix type param tests for suites with many cases
When there were many cases (two digits or more) the "prettier" would fail to recognize the pretty part leaving the test name unprocessed. The fix made sure the processing would work correctly, irrespective of the case number. Before the fix, for the following input: TypedSuite/1. # TypeParam = int case TypedSuite/10. # TypeParam = char case The output would be: TypedSuite/int.case TypedSuite/10. # TypeParam = char.case Now the output will be: TypedSuite/int.case TypedSuite/char.case
-rw-r--r--Modules/GoogleTestAddTests.cmake2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt12
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt4
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt4
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt4
-rw-r--r--Tests/RunCMake/GoogleTest/fake_gtest.cpp8
6 files changed, 24 insertions, 10 deletions
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index a10b5d0..671127a 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -136,7 +136,7 @@ function(gtest_discover_tests_impl)
# Module; remove trailing '.' to get just the name...
string(REGEX REPLACE "\\.( *#.*)?$" "" suite "${line}")
if(line MATCHES "#" AND NOT _NO_PRETTY_TYPES)
- string(REGEX REPLACE "/[0-9]\\.+ +#.*= +" "/" pretty_suite "${line}")
+ string(REGEX REPLACE "/[0-9]+\\.+ +#.*= +" "/" pretty_suite "${line}")
else()
set(pretty_suite "${suite}")
endif()
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt
index fe8f273..f21e579 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt
@@ -1,7 +1,9 @@
Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change
- Test #1: typed/short\.case
- Test #2: typed/float\.case
- Test #3: ns\.typed/short\.case
- Test #4: ns\.typed/float\.case
+ Test #[0-9]+: typed/short\.case
+ Test #[0-9]+: typed/float\.case
+ Test #[0-9]+: typed/char\.case
+ Test #[0-9]+: ns\.typed/short\.case
+ Test #[0-9]+: ns\.typed/float\.case
+ Test #[0-9]+: ns\.typed/char\.case
-Total Tests: 4
+Total Tests: [0-9]+
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt
index 01b39c3..e5b44a9 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt
@@ -23,10 +23,14 @@ Test project .*
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:typed/float\.case!1
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:typed/char\.case!1
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!1 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/short\.case!1
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!1 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/float\.case!1
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!1 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:ns\.typed/char\.case!1
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!1 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:value/test\.case/1!1
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:value/test\.case/"foo"!1
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt
index 796e20c..71dba89 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt
@@ -23,10 +23,14 @@ Test project .*
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:typed/float\.case!2
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:typed/char\.case!2
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!2 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/short\.case!2
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!2 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/float\.case!2
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!2 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:ns\.typed/char\.case!2
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!2 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:value/test\.case/1!2
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:value/test\.case/"foo"!2
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt
index 0f7dde7..21f95e9 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt
@@ -3,10 +3,14 @@ Test project .*
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!4 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:typed/float\.case!4
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!4 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:typed/char\.case!4
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!4 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/short\.case!4
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!4 \.+ +Passed +[0-9.]+ sec
*Start +[0-9]+: TEST:ns\.typed/float\.case!4
*[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!4 \.+ +Passed +[0-9.]+ sec
+ *Start +[0-9]+: TEST:ns\.typed/char\.case!4
+ *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!4 \.+ +Passed +[0-9.]+ sec
100% tests passed, 0 tests failed out of [0-9]+
diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp
index 183e106..e6f74aa 100644
--- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp
+++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp
@@ -36,11 +36,11 @@ int main(int argc, char** argv)
if (!is_basic_only) {
const char* typed_suite_names[] = { "typed", "ns.typed" };
for (size_t i = 0; i < ARRAY_SIZE(typed_suite_names); i++) {
- std::cout << typed_suite_names[i] << "/0. # TypeParam = short"
- << std::endl;
+ std::cout << typed_suite_names[i] << "/0. # TypeParam = short\n";
std::cout << " case" << std::endl;
- std::cout << typed_suite_names[i] << "/1. # TypeParam = float"
- << std::endl;
+ std::cout << typed_suite_names[i] << "/1. # TypeParam = float\n";
+ std::cout << " case" << std::endl;
+ std::cout << typed_suite_names[i] << "/42. # TypeParam = char\n";
std::cout << " case" << std::endl;
}
}