summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-03-31 12:46:39 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-03-31 12:46:39 +0000
commit46cc7df98a4dbc84fb2fceff5e590e1ab5a9d11b (patch)
tree5e5ec42128d2fe1b750197cd77c18401202cea9f
parent50c374f37aba47c8a818a221efb1d06a426deb87 (diff)
downloadbcm5719-llvm-46cc7df98a4dbc84fb2fceff5e590e1ab5a9d11b.tar.gz
bcm5719-llvm-46cc7df98a4dbc84fb2fceff5e590e1ab5a9d11b.zip
Use the current working directory in the glob expansion
This fixes tests that do things like mkdir <dir> cd <dir> .. <cmd> *.foo llvm-svn: 299209
-rw-r--r--llvm/utils/lit/lit/ShCommands.py9
-rw-r--r--llvm/utils/lit/lit/TestRunner.py12
2 files changed, 13 insertions, 8 deletions
diff --git a/llvm/utils/lit/lit/ShCommands.py b/llvm/utils/lit/lit/ShCommands.py
index 0c4c20519dc..01e91c55da9 100644
--- a/llvm/utils/lit/lit/ShCommands.py
+++ b/llvm/utils/lit/lit/ShCommands.py
@@ -48,9 +48,14 @@ class GlobItem:
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:
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 2e6c37c0f31..d3f1c2a4a5b 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -142,15 +142,15 @@ def executeShCmd(cmd, shenv, results, timeout=0):
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 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
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 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
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.
OpenPOWER on IntegriCloud