[llvm-commits] [llvm] r82520 - /llvm/trunk/utils/lit/TestRunner.py

Daniel Dunbar daniel at zuster.org
Mon Sep 21 21:44:26 PDT 2009


Author: ddunbar
Date: Mon Sep 21 23:44:26 2009
New Revision: 82520

URL: http://llvm.org/viewvc/llvm-project?rev=82520&view=rev
Log:
lit: When executing commands internally, perform PATH resolution ourselves.

Modified:
    llvm/trunk/utils/lit/TestRunner.py

Modified: llvm/trunk/utils/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestRunner.py?rev=82520&r1=82519&r2=82520&view=diff

==============================================================================
--- llvm/trunk/utils/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/TestRunner.py Mon Sep 21 23:44:26 2009
@@ -5,6 +5,11 @@
 import Test
 import Util
 
+class InternalShellError(Exception):
+    def __init__(self, command, message):
+        self.command = command
+        self.message = message
+
 def executeCommand(command, cwd=None, env=None):
     p = subprocess.Popen(command, cwd=cwd,
                          stdin=subprocess.PIPE,
@@ -94,6 +99,13 @@
             stderrIsStdout = True
         else:
             stderrIsStdout = False
+
+        # Resolve the executable path ourselves.
+        args = list(j.args)
+        args[0] = Util.which(args[0], cfg.environment['PATH'])
+        if not args[0]:
+            raise InternalShellError(j, '%r: command not found' % j.args[0])
+
         procs.append(subprocess.Popen(j.args, cwd=cwd,
                                       stdin = stdin,
                                       stdout = stdout,
@@ -159,7 +171,12 @@
         return (Test.FAIL, "shell parser error on: %r" % ln)
 
     results = []
-    exitCode = executeShCmd(cmd, test.config, cwd, results)
+    try:
+        exitCode = executeShCmd(cmd, test.config, cwd, results)
+    except InternalShellError,e:
+        out = ''
+        err = e.message
+        exitCode = 255
 
     out = err = ''
     for i,(cmd, cmd_out,cmd_err,res) in enumerate(results):
@@ -225,7 +242,11 @@
         return out,err,exitCode
     else:
         results = []
-        exitCode = executeShCmd(cmd, test.config, cwd, results)
+        try:
+            exitCode = executeShCmd(cmd, test.config, cwd, results)
+        except InternalShellError,e:
+            results.append((e.command, '', e.message + '\n', 255))
+            exitCode = 255
 
     out = err = ''
 





More information about the llvm-commits mailing list