Commit Graph

7 Commits

Author SHA1 Message Date
Alexander Stein
e9ab39eb1d GoogleTest: Add XML_OUTPUT_DIR parameter
When executing googltests in parallel using 'ctest -j n' and using
'--gtest_output=xml' there is a race condition upon file creation.
See googletest issue https://github.com/google/googletest/issues/2506.

As all testcases (potentially) can be run in parallel each testcase has
to create it's own XML JUnit file. EXTRA_ARGS is not suitable because it
is identical per testsuite.
So instead a new (opitional) parameter has been introduced to specify
the storage location for each test of the testsuite.
2020-03-13 10:47:33 -04:00
Ryan Thornton
2ba8ac07ed GoogleTest: Fix CTest not failing if gtest_discover_tests fails
Fixes regression introduced dac201442d (GoogleTest: Optimize gtest_discover_tests, 2020-02-18).

The generated CTest include files has the form:

    if(EXISTS "foo_tests.cmake")
      include("foo_tests.cmake")
    else()
      add_test(foo_NOT_BUILT foo_test_NOT_BUILT)
    endif()

Starting in dac201442d, an empty discovery_timeout_test[1]_tests.cmake was written
as soon as GoogleTestAddTests was processed.

This meant, that even if test discovery would fail (due to a crash or timeout in the executable),
we would always produce an empty CTest file.

So instead of reporting:
   Unable to find executable: foo_NOT_BUILT
   Errors while running CTest

We instead get:
   No tests were found!!!

To fix the problem, we WRITE the file on the first call to flush_script,
thus creating the file once we know we have valid output
and the call to gtest_discover_tests hasn't failed.

After creating the file, we then set the mode to APPEND
and append to the file for every subsequent call.
2020-03-11 15:11:00 -05:00
Steffen Seckler
dac201442d GoogleTest: Optimize gtest_discover_tests
Prior to this, `gtest_discover_tests` could take multiple minutes if
many tests are present.  This behavior was caused by a repeated addition
to the variable `script` in the `add_command` function using:

    set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)

This takes very long for large variables.

This commit flushes the contents of the variable to ${CTEST_FILE} after
a certain size of the variable is reached.

In addition:

- cmake_minimum_required(VERSION ${CMAKE_VERSION}) is set to allow usage
  of new policies.  In particular, CMP0053 speeds up variable expansion.
- No longer appends strings using set(), but instead uses string(APPEND).
- An additional buffer for the tests variable is set.
2020-02-25 09:03:56 -05:00
Nehal J Wani
3bbf77fa01 Specify WORKING_DIRECTORY to execute_process() in GoogleTestAddTests 2018-12-28 17:44:51 +05:30
Matthew Woehlke
29731d8919 GoogleTest: Add timeout to discovery
Add a TIMEOUT option to gtest_discover_tests. This provides a
work-around in case a test goes out to lunch, rather than causing the
build to simply hang. (Although this is still a problem with the user's
project, hanging the build is not cool, especially in the case of
automatically running CI builds. It is much preferred that the build
should actively fail in this case, and it is trivially easy for us to
implement that.)
2017-12-06 07:37:48 -05:00
Matthew Woehlke
e99e39829b GoogleTest: Improve gtest_discover_tests messages
Adjust the formatting of error messages produced when test discovery
goes wrong, in order to avoid spurious line breaking.
2017-11-30 15:07:52 -05:00
Matthew Woehlke
bfcda4013a Add dynamic test discovery for for Google Test
Add a new gtest_discover_tests function to GoogleTest.cmake,
implementing dynamic test discovery (i.e. tests are discovered by
actually running the test executable and asking for the list of
available tests, which is used to dynamically declare the tests) rather
than the source-parsing approach used by gtest_add_tests. Compared to
the source-parsing approach, this has the advantage of being robust
against users declaring tests in unusual ways, and much better support
for advanced features such as parameterized tests.

A unit test, modeled after the TEST_INCLUDE_DIR[S] test, is also
included. Note that the unit test does not actually require that Google
Test is available. The new functionality does not actually depend on
Google Test as such; it only requires that the test executable lists
tests in the expected format when invoked with --gtest_list_tests, which
the unit test can fake readily.
2017-07-27 09:47:28 -04:00