1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[lit] GoogleTest framework should report failures if test binary crashes

lit runs a gtest executable multiple times. First it runs it to
discover tests, then later it runs the executable again for each test.
However, if the discovery fails (perhaps because of a broken
executable), then no tests were previously run and no failures were
reported.  This patch creates a dummy test if discovery fails, which
will later fail when test are run and be reported as a failure.

Differential Revision: https://reviews.llvm.org/D80096
This commit is contained in:
Stephen Neuendorffer 2020-05-17 17:41:39 -07:00
parent 6863d97f67
commit fb36a60665
4 changed files with 24 additions and 0 deletions

View File

@ -41,6 +41,14 @@ class GoogleTest(TestFormat):
litConfig.warning(
"unable to discover google-tests in %r: %s. Process output: %s"
% (path, sys.exc_info()[1], exc.output))
# This doesn't look like a valid gtest file. This can
# have a number of causes, none of them good. For
# instance, we could have created a broken executable.
# Alternatively, someone has cruft in their test
# directory. If we don't return a test here, then no
# failures will get reported, so return a dummy test name
# so that the failure is reported later.
yield 'failed_to_discover_tests_from_gtest'
return
nested_tests = []

View File

@ -0,0 +1,3 @@
import lit.formats
config.name = 'googletest-discovery-failed'
config.test_format = lit.formats.GoogleTest('subdir', 'Test')

View File

@ -0,0 +1,3 @@
#!/usr/bin/env python
raise SystemExit("We are not a valid gtest executable!")

View File

@ -0,0 +1,10 @@
# Check for correct error message when discovery of tests fails.
#
# RUN: not %{lit} -j 1 -v %{inputs}/googletest-discovery-failed > %t.cmd.out
# RUN: FileCheck < %t.cmd.out %s
# CHECK: -- Testing:
# CHECK: Failing Tests (1):
# CHECK: googletest-discovery-failed :: subdir/OneTest.py/failed_to_discover_tests_from_gtest
# CHECK: Unexpected Failures: 1