Skip to content

Commit 0231227

Browse files
Reapply "[lit] GoogleTest framework should report failures if test binary crashes"
This reverts commit 78dea0e. The offending lldb test (which is a real bug exposed by this patch) has been disabled on windows (see a67b2fa) and lldb is queued for inclusion into precommit testing, which would have caught this. Differential Revision: https://reviews.llvm.org/D80389
1 parent 62fb3fa commit 0231227

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

llvm/utils/lit/lit/formats/googletest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def getGTestTests(self, path, litConfig, localConfig):
4141
litConfig.warning(
4242
"unable to discover google-tests in %r: %s. Process output: %s"
4343
% (path, sys.exc_info()[1], exc.output))
44+
# This doesn't look like a valid gtest file. This can
45+
# have a number of causes, none of them good. For
46+
# instance, we could have created a broken executable.
47+
# Alternatively, someone has cruft in their test
48+
# directory. If we don't return a test here, then no
49+
# failures will get reported, so return a dummy test name
50+
# so that the failure is reported later.
51+
yield 'failed_to_discover_tests_from_gtest'
4452
return
4553

4654
nested_tests = []
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import lit.formats
2+
config.name = 'googletest-discovery-failed'
3+
config.test_format = lit.formats.GoogleTest('subdir', 'Test')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
3+
raise SystemExit("We are not a valid gtest executable!")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Check for correct error message when discovery of tests fails.
2+
#
3+
# RUN: not %{lit} -j 1 -v %{inputs}/googletest-discovery-failed > %t.cmd.out
4+
# RUN: FileCheck < %t.cmd.out %s
5+
6+
7+
# CHECK: -- Testing:
8+
# CHECK: Failing Tests (1):
9+
# CHECK: googletest-discovery-failed :: subdir/OneTest.py/failed_to_discover_tests_from_gtest
10+
# CHECK: Unexpected Failures: 1

0 commit comments

Comments
 (0)