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

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 17 18:06:04 PDT 2020


stephenneuendorffer created this revision.
Herald added subscribers: llvm-commits, delcypher.
Herald added a project: LLVM.
stephenneuendorffer added a reviewer: mehdi_amini.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80096

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


Index: llvm/utils/lit/lit/formats/googletest.py
===================================================================
--- llvm/utils/lit/lit/formats/googletest.py
+++ 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 = []


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80096.264522.patch
Type: text/x-patch
Size: 956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/1370b135/attachment.bin>


More information about the llvm-commits mailing list