diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 09:42:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 09:42:24 +0000 |
commit | 8fe83f18c711df71dd3701a933e06191fddc06a4 (patch) | |
tree | 9b0fe2f49cc91a5b940e66325d56c506918ecee0 | |
parent | 772a5e540dc2d711b0497db8a7d129c194fbb38c (diff) |
MultiTestRunner.py improvements.
- Not improved: the horribly lousy name. :)
- Suppress stderr when capturing output.
- Rewrite which() to do the right PATH search instead of being lazy and
shelling out to 'which'.
- On Windows, run scripts as batch files (via 'cmd /c ...').
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77058 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | utils/test/TestRunner.py | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/utils/test/TestRunner.py b/utils/test/TestRunner.py index 6c6de1bf66..d82ddac2d8 100755 --- a/utils/test/TestRunner.py +++ b/utils/test/TestRunner.py @@ -16,7 +16,9 @@ # import errno +import hashlib import os +import platform import re import signal import subprocess @@ -27,6 +29,8 @@ import sys # FIXME: Find a better place for this hack. os.environ['COLUMNS'] = '0' +kSystemName = platform.system() + class TestStatus: Pass = 0 XFail = 1 @@ -109,6 +113,8 @@ def runOneTest(FILENAME, SUBST, OUTPUT, TESTNAME, CLANG, CLANGCC, FILENAME = os.path.abspath(FILENAME) SCRIPT = OUTPUT + '.script' + if kSystemName == 'Windows': + SCRIPT += '.bat' TEMPOUTPUT = OUTPUT + '.tmp' substitutions = [('%s',SUBST), @@ -149,7 +155,12 @@ def runOneTest(FILENAME, SUBST, OUTPUT, TESTNAME, CLANG, CLANGCC, outputFile = open(OUTPUT,'w') p = None try: - p = subprocess.Popen(["/bin/sh",SCRIPT], + if kSystemName == 'Windows': + command = ['cmd','/c', SCRIPT] + else: + command = ['/bin/sh', SCRIPT] + + p = subprocess.Popen(command, cwd=os.path.dirname(FILENAME), stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -170,7 +181,10 @@ def runOneTest(FILENAME, SUBST, OUTPUT, TESTNAME, CLANG, CLANGCC, SCRIPT_STATUS = not SCRIPT_STATUS if useValgrind: - VG_OUTPUT = capture(['/bin/sh','-c','cat %s.*'%(VG_OUTPUT)]) + if kSystemName == 'Windows': + raise NotImplementedError,'Cannot run valgrind on windows' + else: + VG_OUTPUT = capture(['/bin/sh','-c','cat %s.*'%(VG_OUTPUT)]) VG_STATUS = len(VG_OUTPUT) else: VG_STATUS = 0 @@ -200,16 +214,30 @@ def runOneTest(FILENAME, SUBST, OUTPUT, TESTNAME, CLANG, CLANGCC, return TestStatus.Pass def capture(args): - p = subprocess.Popen(args, stdout=subprocess.PIPE) + p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out,_ = p.communicate() return out def which(command): + # Check for absolute match first. + if os.path.exists(command): + return command + # Would be nice if Python had a lib function for this. - res = capture(['which',command]) - res = res.strip() - if res and os.path.exists(res): - return res + paths = os.environ.get('PATH') + if not paths: + paths = os.defpath + + # Get suffixes to search. + pathext = os.environ.get('PATHEXT', '').split(os.pathsep) + + # Search the paths... + for path in paths.split(os.pathsep): + for ext in pathext: + p = os.path.join(path, command + ext) + if os.path.exists(p): + return p + return None def inferClang(): @@ -240,7 +268,11 @@ def inferClangCC(clang): # Otherwise try adding -cc since we expect to be looking in a build # directory. - clangcc = which(clang + '-cc') + if clang.endswith('.exe'): + clangccName = clang[:-4] + '-cc.exe' + else: + clangccName = clang + '-cc' + clangcc = which(clangccName) if not clangcc: # Otherwise ask clang. res = capture([clang, '-print-prog-name=clang-cc']) |