[PATCH] D24111: [lit] Fail testing if a googletest executable crashes during test discovery

Greg Parker via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 16:58:48 PDT 2016

gparker42 created this revision.
gparker42 added a reviewer: ddunbar.
gparker42 added a subscriber: llvm-commits.

googletest formatted tests are discovered by running the test executable. Previously testing would silently succeed if the test executable crashed during the discovery process. Now testing fails with "error: unable to discover google-tests ..." if the test executable exits with a non-zero status.



Index: utils/lit/lit/util.py
--- utils/lit/lit/util.py
+++ utils/lit/lit/util.py
@@ -65,10 +65,13 @@
 def capture(args, env=None):
     """capture(command) - Run the given command (or argv list) in a shell and
-    return the standard output."""
+    return the standard output. Raises a CalledProcessError if the command
+    exits with a non-zero status."""
     p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
     out,_ = p.communicate()
+    if p.returncode != 0:
+        raise subprocess.CalledProcessError(cmd=args, returncode=p.returncode)
     return convert_string(out)
 def which(command, paths = None):
Index: utils/lit/lit/formats/googletest.py
--- utils/lit/lit/formats/googletest.py
+++ utils/lit/lit/formats/googletest.py
@@ -35,7 +35,8 @@
               lines = lines.replace('\r', '')
             lines = lines.split('\n')
-            litConfig.error("unable to discover google-tests in %r" % path)
+            litConfig.error("unable to discover google-tests in %r: %s"
+                            % (path, sys.exc_info()[1]))
             raise StopIteration
         nested_tests = []

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24111.69929.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160831/51f550d2/attachment.bin>

More information about the llvm-commits mailing list