[cfe-commits] r77075 - in /cfe/trunk: test/Makefile utils/test/TestRunner.py

Daniel Dunbar daniel at zuster.org
Sat Jul 25 08:26:29 PDT 2009


Author: ddunbar
Date: Sat Jul 25 10:26:08 2009
New Revision: 77075

URL: http://llvm.org/viewvc/llvm-project?rev=77075&view=rev
Log:
MultiTestRunner: Make sure to point at src dir, for out of tree builds.

Factor out routine for executing the script commands.

Modified:
    cfe/trunk/test/Makefile
    cfe/trunk/utils/test/TestRunner.py

Modified: cfe/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Makefile?rev=77075&r1=77074&r2=77075&view=diff

==============================================================================
--- cfe/trunk/test/Makefile (original)
+++ cfe/trunk/test/Makefile Sat Jul 25 10:26:08 2009
@@ -2,7 +2,7 @@
 include $(LEVEL)/Makefile.common
 
 # Test in all immediate subdirectories if unset.
-TESTDIRS ?= .
+TESTDIRS ?= $(PROJ_SRC_DIR)
 
 ifndef TESTARGS
 ifdef VERBOSE

Modified: cfe/trunk/utils/test/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/test/TestRunner.py?rev=77075&r1=77074&r2=77075&view=diff

==============================================================================
--- cfe/trunk/utils/test/TestRunner.py (original)
+++ cfe/trunk/utils/test/TestRunner.py Sat Jul 25 10:26:08 2009
@@ -57,6 +57,35 @@
             if e.errno != errno.EEXIST:
                 raise
 
+def executeScript(script, commands, cwd):
+    # Write script file
+    f = open(script,'w')
+    if kSystemName == 'Windows':
+        f.write('\nif %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
+    else:
+        f.write(' &&\n'.join(commands))
+    f.write('\n')
+    f.close()
+
+    if kSystemName == 'Windows':
+        command = ['cmd','/c', script]
+    else:
+        command = ['/bin/sh', script]
+
+    p = subprocess.Popen(command, cwd=cwd,
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE,
+                         env=kChildEnv)
+    out,err = p.communicate()
+    exitCode = p.wait()
+
+    # Detect Ctrl-C in subprocess.
+    if exitCode == -signal.SIGINT:
+        raise KeyboardInterrupt
+
+    return out, err, exitCode
+
 import StringIO
 def runOneTest(testPath, tmpBase, clang, clangcc):
     # Make paths absolute.
@@ -119,37 +148,8 @@
         # Strip off '&&'
         scriptLines[i] = ln[:-2]
 
-    # Write script file
-    f = open(script,'w')
-    if kSystemName == 'Windows':
-        f.write('\nif %ERRORLEVEL% NEQ 0 EXIT\n'.join(scriptLines))
-    else:
-        f.write(' &&\n'.join(scriptLines))
-    f.write('\n')
-    f.close()
-
-    p = None
-    try:
-        if kSystemName == 'Windows':
-            command = ['cmd','/c', script]
-        else:
-            command = ['/bin/sh', script]
-        
-        p = subprocess.Popen(command,
-                             cwd=os.path.dirname(testPath),
-                             stdin=subprocess.PIPE,
-                             stdout=subprocess.PIPE,
-                             stderr=subprocess.PIPE,
-                             env=kChildEnv)
-        out,err = p.communicate()
-        exitCode = p.wait()
-
-        # Detect Ctrl-C in subprocess.
-        if exitCode == -signal.SIGINT:
-            raise KeyboardInterrupt
-    except KeyboardInterrupt:
-        raise
-
+    out, err, exitCode = executeScript(script, scriptLines, 
+                                       cwd=os.path.dirname(testPath))
     if xfailLines:
         ok = exitCode != 0
         status = (TestStatus.XPass, TestStatus.XFail)[ok]





More information about the cfe-commits mailing list