[lit] Implement support of per test timeout in lit.
[oota-llvm.git] / utils / lit / lit / formats / googletest.py
index a1ecced52a8e5863019fc536357a4a140571e9ed..5b19d4e638f945285a97746b92b90f5457e4d84a 100644 (file)
@@ -53,7 +53,8 @@ class GoogleTest(TestFormat):
             ln = ln[index*2:]
             if ln.endswith('.'):
                 nested_tests.append(ln)
-            elif ln.startswith('DISABLED_'):
+            elif any([name.startswith('DISABLED_')
+                      for name in nested_tests + [ln]]):
                 # Gtest will internally skip these tests. No need to launch a
                 # child process for it.
                 continue
@@ -108,8 +109,15 @@ class GoogleTest(TestFormat):
         if litConfig.noExecute:
             return lit.Test.PASS, ''
 
-        out, err, exitCode = lit.util.executeCommand(
-            cmd, env=test.config.environment)
+        try:
+            out, err, exitCode = lit.util.executeCommand(
+                cmd, env=test.config.environment,
+                timeout=litConfig.maxIndividualTestTime)
+        except lit.util.ExecuteCommandTimeoutException:
+            return (lit.Test.TIMEOUT,
+                    'Reached timeout of {} seconds'.format(
+                        litConfig.maxIndividualTestTime)
+                   )
 
         if exitCode:
             return lit.Test.FAIL, out + err