1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

GoogleTest: Fix name generation for XML_OUTPUT_DIR

The Google test framework allows to write the results into an XML file
since commit e9ab39eb1d (GoogleTest: Add XML_OUTPUT_DIR parameter,
2020-03-06, v3.18.0-rc1~538^2~2).  This file is passed on the command
line: `--gtest_output=xml:FILE_NAME`.

The module allows to specify a directory to save those files with
**TEST_XML_OUTPUT_PARAM**.

If the option is set, the filename will be set to
`${prefix}${pretty_suite}.${pretty_test}${suffix}.xml`.

The pretty names contain parameters for the tests, if
value-parameterized tests are used. These parameters may not be safe to
use in file names.

There are two possible options:

1. sanitize the file name
2. omit the values and use the internal numbering of gtest

This commit chose option 2. The testname needs to be a valid C++
identifier and should therefore be reasonable for a filename.

Note that the generated names contain slashes. This will lead to
subdirectories, but works on both Linux and Windows.

Fixes: #20877
This commit is contained in:
Stefan Floeren
2020-06-25 14:57:43 +00:00
committed by Brad King
parent e66fe75792
commit 75aa3ee7e7

View File

@@ -112,7 +112,7 @@ function(gtest_discover_tests_impl)
string(REGEX REPLACE "^DISABLED_" "" pretty_test "${pretty_test}")
string(REGEX REPLACE "#.*" "" test "${test}")
if(NOT "${_TEST_XML_OUTPUT_DIR}" STREQUAL "")
set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${_TEST_XML_OUTPUT_DIR}/${prefix}${pretty_suite}.${pretty_test}${suffix}.xml")
set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${_TEST_XML_OUTPUT_DIR}/${prefix}${suite}.${test}${suffix}.xml")
else()
unset(TEST_XML_OUTPUT_PARAM)
endif()