[llvm] r242941 - [lit] Fix launching executables relative to the cwd after 'cd'

Reid Kleckner reid at kleckner.net
Wed Jul 22 14:35:28 PDT 2015

Author: rnk
Date: Wed Jul 22 16:35:27 2015
New Revision: 242941

URL: http://llvm.org/viewvc/llvm-project?rev=242941&view=rev
[lit] Fix launching executables relative to the cwd after 'cd'

This was affecting test/asan/TestCases/Windows/coverage-basic.cc in
compiler-rt. It does something like:

  cd %T/mydir
  %clang %s -o t.exe

Previously, we'd end up looking for t.exe relative to the cwd of the lit
process, not the cwd of the test.


Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=242941&r1=242940&r2=242941&view=diff
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Wed Jul 22 16:35:27 2015
@@ -178,7 +178,14 @@ def executeShCmd(cmd, shenv, results):
         # Resolve the executable path ourselves.
         args = list(j.args)
-        executable = lit.util.which(args[0], cmd_shenv.env['PATH'])
+        executable = None
+        # For paths relative to cwd, use the cwd of the shell environment.
+        if args[0].startswith('.'):
+            exe_in_cwd = os.path.join(cmd_shenv.cwd, args[0])
+            if os.path.isfile(exe_in_cwd):
+                executable = exe_in_cwd
+        if not executable:
+            executable = lit.util.which(args[0], cmd_shenv.env['PATH'])
         if not executable:
             raise InternalShellError(j, '%r: command not found' % j.args[0])

More information about the llvm-commits mailing list