[PATCH] D31510: Use the current working directory in the glob expansion
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 14:25:17 PDT 2017
rafael created this revision.
Herald added a reviewer: modocache.
This fixes tests that do things like
mkdir <dir>
cd <dir>
..
<cmd> *.foo
https://reviews.llvm.org/D31510
Files:
utils/lit/lit/ShCommands.py
utils/lit/lit/TestRunner.py
Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -142,15 +142,15 @@
return (finalExitCode, timeoutInfo)
-def expand_glob(arg):
+def expand_glob(arg, cwd):
if isinstance(arg, GlobItem):
- return arg.resolve()
+ return arg.resolve(cwd)
return [arg]
-def expand_glob_expressions(args):
+def expand_glob_expressions(args, cwd):
result = [args[0]]
for arg in args[1:]:
- result.extend(expand_glob(arg))
+ result.extend(expand_glob(arg, cwd))
return result
def quote_windows_command(seq):
@@ -325,7 +325,7 @@
else:
if r[2] is None:
redir_filename = None
- name = expand_glob(r[0])
+ name = expand_glob(r[0], cmd_shenv.cwd)
if len(name) != 1:
raise InternalShellError(j,"Unsupported: glob in redirect expanded to multiple files")
name = name[0]
@@ -389,7 +389,7 @@
args[i] = f.name
# Expand all glob expressions
- args = expand_glob_expressions(args)
+ args = expand_glob_expressions(args, cmd_shenv.cwd)
# On Windows, do our own command line quoting for better compatibility
# with some core utility distributions.
Index: utils/lit/lit/ShCommands.py
===================================================================
--- utils/lit/lit/ShCommands.py
+++ utils/lit/lit/ShCommands.py
@@ -48,9 +48,14 @@
return (self.pattern == other.pattern)
- def resolve(self):
+ def resolve(self, cwd):
import glob
- results = glob.glob(self.pattern)
+ import os
+ if os.path.isabs(self.pattern):
+ abspath = self.pattern
+ else:
+ abspath = os.path.join(cwd, self.pattern)
+ results = glob.glob(abspath)
return [self.pattern] if len(results) == 0 else results
class Pipeline:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31510.93542.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170330/254a1c94/attachment.bin>
More information about the llvm-commits
mailing list