[PATCH] D100043: [lit] Fix compatibility with upstream gtest

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 08:02:49 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG14a793ab0589: [lit] Fix compatibility with upstream gtest (authored by lzaoral, committed by probinson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100043/new/

https://reviews.llvm.org/D100043

Files:
  llvm/utils/lit/lit/formats/googletest.py
  llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py


Index: llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py
===================================================================
--- llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py
+++ llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py
@@ -1,13 +1,14 @@
 #!/usr/bin/env python
 
+import os
 import sys
 
 if len(sys.argv) != 2:
     raise ValueError("unexpected number of args")
 
 if sys.argv[1] == "--gtest_list_tests":
-    print("""\
-Running main() from gtest_main.cc
+    print(f"""\
+Running main() from {os.getcwd()}/gtest_main.cc
 FirstTest.
   subTestA
   subTestB
Index: llvm/utils/lit/lit/formats/googletest.py
===================================================================
--- llvm/utils/lit/lit/formats/googletest.py
+++ llvm/utils/lit/lit/formats/googletest.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 import os
+import re
 import shlex
 import subprocess
 import sys
@@ -53,11 +54,12 @@
             yield 'failed_to_discover_tests_from_gtest'
             return
 
+        upstream_prefix = re.compile('Running main\(\) from .*gtest_main\.cc')
         nested_tests = []
         for ln in output.splitlines(False):  # Don't keep newlines.
             ln = lit.util.to_string(ln)
 
-            if 'Running main() from gtest_main.cc' in ln:
+            if upstream_prefix.fullmatch(ln):
                 # Upstream googletest prints this to stdout prior to running
                 # tests. LLVM removed that print statement in r61540, but we
                 # handle it here in case upstream googletest is being used.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100043.401243.patch
Type: text/x-patch
Size: 1642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/e152e30f/attachment.bin>


More information about the llvm-commits mailing list