[lit] Fix compatibility with upstream gtest
authorLukáš Zaoral <lzaoral@redhat.com>
Wed, 19 Jan 2022 16:01:18 +0000 (08:01 -0800)
committerPaul Robinson <paul.robinson@sony.com>
Wed, 19 Jan 2022 16:02:28 +0000 (08:02 -0800)
Upstream gtest now prints 'Running main() from FILE' instead of
plain 'Running main() from gtest_main.cc'. Thus, all such tests
ended-up being mistakenly marked as UNRESOLVED.

Patch by @lzaoral

Differential Revision: https://reviews.llvm.org/D100043

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

index d8f3d35..5329f57 100644 (file)
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 import os
+import re
 import shlex
 import subprocess
 import sys
@@ -53,11 +54,12 @@ class GoogleTest(TestFormat):
             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.
index 1061e39..aa79a22 100644 (file)
@@ -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