aboutsummaryrefslogtreecommitdiff
path: root/utils/test/TestRunner.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-25 15:26:08 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-25 15:26:08 +0000
commit10aebbb5c8d928c4faa672c47d076cba1edefab7 (patch)
tree1a7c6df60adc1e6973d068cf64dd70bb0604f2c0 /utils/test/TestRunner.py
parenta957d9996e7f7406195e5a954c6a533eeb5bf7fa (diff)
MultiTestRunner: Make sure to point at src dir, for out of tree builds.
Factor out routine for executing the script commands. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/test/TestRunner.py')
-rwxr-xr-xutils/test/TestRunner.py62
1 files changed, 31 insertions, 31 deletions
diff --git a/utils/test/TestRunner.py b/utils/test/TestRunner.py
index 9e8b77e59b..2059b51184 100755
--- a/utils/test/TestRunner.py
+++ b/utils/test/TestRunner.py
@@ -57,6 +57,35 @@ def mkdir_p(path):
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 @@ def runOneTest(testPath, tmpBase, clang, clangcc):
# 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]