Skip to content

GoogleTest: Fix name generation for XML_OUTPUT_DIR

Stefan Floeren requested to merge stefan-floeren/cmake:gtest-xml-output into master

The Google test framework allows to write the results into an XML file since !4433 (merged). 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.

This merge request does not address sanitization of prefix and suffix. This requires further discussions in what should be allowed in there and what not and should be addressed in a different MR (for example: System-specifc characters, and names [NUL], relative paths, ...)

Fixes: #20877 (closed)
Backport: release

Edited by Brad King

Merge request reports