diff --git a/llvm/utils/lit/lit/formats/googletest.py b/llvm/utils/lit/lit/formats/googletest.py --- a/llvm/utils/lit/lit/formats/googletest.py +++ b/llvm/utils/lit/lit/formats/googletest.py @@ -41,6 +41,14 @@ 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 = [] diff --git a/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/DummySubDir/OneTest.py b/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/DummySubDir/OneTest.py new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/DummySubDir/OneTest.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +import sys +import time + +raise SystemExit("We are not a valid gtest executable!") diff --git a/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/lit.cfg b/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/lit.cfg new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/googletest-brokendiscovery/lit.cfg @@ -0,0 +1,4 @@ +import lit.formats +config.name = 'googletest-brokendiscovery' +config.test_format = lit.formats.GoogleTest('DummySubDir', 'Test') + diff --git a/llvm/utils/lit/tests/googletest-brokendiscovery.py b/llvm/utils/lit/tests/googletest-brokendiscovery.py new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/googletest-brokendiscovery.py @@ -0,0 +1,11 @@ +# Check that the per test timeout is enforced when running GTest tests. +# +# RUN: not %{lit} -j 1 -v %{inputs}/googletest-brokendiscovery > %t.cmd.out +# RUN: FileCheck < %t.cmd.out %s + + +# CHECK: -- Testing: +# CHECK: Failing Tests (1): +# CHECK: googletest-brokendiscovery :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/failed_to_discover_tests_from_gtest +# CHECK: Unexpected Failures: 1 +