diff options
author | Evgeniy Shcherbina <ixsci@pm.me> | 2022-01-05 08:10:03 (GMT) |
---|---|---|
committer | Evgeniy Shcherbina <ixsci@pm.me> | 2022-01-11 06:00:53 (GMT) |
commit | 8b85b10fb36e5d1ef4d639cd841cf637d64df3c8 (patch) | |
tree | 2aa3ed3f342a4fcb059a348cce2f907f4a53d2b6 /Tests/RunCMake | |
parent | 8f977a5c92f53e4ab17d08889857f882467a1e47 (diff) | |
download | CMake-8b85b10fb36e5d1ef4d639cd841cf637d64df3c8.zip CMake-8b85b10fb36e5d1ef4d639cd841cf637d64df3c8.tar.gz CMake-8b85b10fb36e5d1ef4d639cd841cf637d64df3c8.tar.bz2 |
GoogleTest: Add handling for square brackets in test names
If a test name contains a square bracket (due to parameters) then it
breaks gtest_discovery_test() function in some not-so-predictable
way. That happens due to the special meaning these brackets have in
the CMake language and they can't be escaped universally.
So the following treatment has been implemented:
* Every occurrence of ('[' | ']') in a test name gets replaced with
the corresponding placeholder ("__osb_*" | "__csb_*") before the
Google Test output processing and gets replaced back before adding
a new test to CTest, keeping the original test name intact in the
CTest output.
The placeholders are chosen that way to minimize the chance of
clashing with something in the user tests but even if the default
ones would clash with something then they are enhanced to not clash
with anything (hence "_*" at the placeholder's end).
* The GTest output gets searched for the default test name guards
("[=[" | "]=]") and if they are found a new one gets generated until
the one is found which can safely encompass any test name. The
search is quite simple: find the least amount of '=' which would
allow escaping any test.
* The resulting ${TEST_LIST} variable will contain every test but
tests with square brackets as there is no way to make sure such
tests won't break the list altogether.
Fixes: #23039
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt | 16 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt | 22 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/fake_gtest.cpp | 4 |
3 files changed, 39 insertions, 3 deletions
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index acff3bc..9c0b775 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt @@ -41,12 +41,28 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"backslash\\"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"\${var}"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"\${var}"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/'\['!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/'\['!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"\]\]=\]"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"\]\]=\]"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"__osbtext"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"__osbtext"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"__csb___text"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"__csb___text"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"semicolon;"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"semicolon;"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"backslash\\"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"backslash\\"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"\${var}"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"\${var}"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/'\['!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/'\['!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"\]\]=\]"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"\]\]=\]"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"__osbtext"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__osbtext"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!1 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt index 703bae2..b0210c6 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -41,18 +41,34 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"backslash\\"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"\${var}"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"\${var}"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/'\['!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/'\['!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"\]\]=\]"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"\]\]=\]"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"__osbtext"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"__osbtext"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:param/special\.case/"__csb___text"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"__csb___text"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"semicolon;"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"semicolon;"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"backslash\\"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"backslash\\"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"\${var}"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"\${var}"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/'\['!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/'\['!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"\]\]=\]"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"\]\]=\]"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"__osbtext"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__osbtext"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!2 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ Total Test time \(real\) = +[0-9.]+ sec The following tests did not run: -[ 0-9]+ - TEST:basic\.disabled_case!2 \(Disabled\) -[ 0-9]+ - TEST:ns\.basic\.disabled_case!2 \(Disabled\) -[ 0-9]+ - TEST:disabled\.case!2 \(Disabled\) +[ 0-9]+- TEST:basic\.disabled_case!2 \(Disabled\) +[ 0-9]+- TEST:ns\.basic\.disabled_case!2 \(Disabled\) +[ 0-9]+- TEST:disabled\.case!2 \(Disabled\) diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp index 36f1d3c..aa6468c 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -57,6 +57,10 @@ int main(int argc, char** argv) std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; + std::cout << " case/3 # GetParam() = '['" << std::endl; + std::cout << " case/4 # GetParam() = \"]]=]\"" << std::endl; + std::cout << " case/5 # GetParam() = \"__osbtext\"" << std::endl; + std::cout << " case/6 # GetParam() = \"__csb___text\"" << std::endl; } } return 0; |