[lit] Fix running gtest type-parameterized tests on Windows
authorReid Kleckner <reid@kleckner.net>
Mon, 6 Apr 2015 21:49:55 +0000 (21:49 +0000)
committerReid Kleckner <reid@kleckner.net>
Mon, 6 Apr 2015 21:49:55 +0000 (21:49 +0000)
The '/' character in the test name of a type-parameterized test is not a
path separator, and should not be '\' on Windows. We were passing a test
name to --gtest_filter which found no tests, so the exit code was zero,
indicating a passed test.

This bug has been here since r84387 in 2009, when Jeff Yasskin added the
original lit support for type-paratermized tests. Somewhere along the
line some of the ValueMapTests started failing, but we can fix those
separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234242 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/IR/ValueMapTest.cpp
utils/lit/lit/formats/googletest.py

index a6bad71cf630fb4cf11d651a3d9a8fed11d7326e..1431a8d87de4a42c84cfd9dbf7aadd6dad3f3f2a 100644 (file)
@@ -194,7 +194,8 @@ struct LockMutex : ValueMapConfig<KeyT, MutexT> {
   }
   static MutexT *getMutex(const ExtraData &Data) { return Data.M; }
 };
-#if LLVM_ENABLE_THREADS
+// FIXME: These tests started failing on Windows.
+#if LLVM_ENABLE_THREADS && !defined(LLVM_ON_WIN32)
 TYPED_TEST(ValueMapTest, LocksMutex) {
   sys::Mutex M(false);  // Not recursive.
   bool CalledRAUW = false, CalledDeleted = false;
index 59ac3c5cb370064e954f0efdbba4ebab5b3e5ccb..748dcc7fc67cf5d62dd34fd593f93d677ea27be1 100644 (file)
@@ -95,7 +95,7 @@ class GoogleTest(TestFormat):
             # Handle GTest parametrized and typed tests, whose name includes
             # some '/'s.
             testPath, namePrefix = os.path.split(testPath)
-            testName = os.path.join(namePrefix, testName)
+            testName = namePrefix + '/' + testName
 
         cmd = [testPath, '--gtest_filter=' + testName]
         if litConfig.useValgrind:
@@ -107,7 +107,14 @@ class GoogleTest(TestFormat):
         out, err, exitCode = lit.util.executeCommand(
             cmd, env=test.config.environment)
 
-        if not exitCode:
-            return lit.Test.PASS,''
+        if exitCode:
+            return lit.Test.FAIL, out + err
+
+        passing_test_line = '[  PASSED  ] 1 test.'
+        if passing_test_line not in out:
+            msg = ('Unable to find %r in gtest output:\n\n%s%s' %
+                   (passing_test_line, out, err))
+            return lit.Test.UNRESOLVED, msg
+
+        return lit.Test.PASS,''
 
-        return lit.Test.FAIL, out + err