summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-03-30 20:48:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-03-30 20:48:58 +0000
commitec1bc0f584377951429fe3c0f469d260c05c54b6 (patch)
treeae5a3d0e54915c6ec0187f78e9597718347afbce
parent66611d94ad0067eb31c6c4b0ebe84110ec541b13 (diff)
downloadbcm5719-llvm-ec1bc0f584377951429fe3c0f469d260c05c54b6.tar.gz
bcm5719-llvm-ec1bc0f584377951429fe3c0f469d260c05c54b6.zip
lit: support redirect from globs
This adds support for commands like FileCheck < foobar* which is used by some asan tests because the file they want to read has a pid in the name. llvm-svn: 299111
-rw-r--r--llvm/utils/lit/lit/TestRunner.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 9cb0ae09923..894159ee7bf 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -142,13 +142,15 @@ def executeShCmd(cmd, shenv, results, timeout=0):
return (finalExitCode, timeoutInfo)
+def expand_glob(arg):
+ if isinstance(arg, GlobItem):
+ return arg.resolve()
+ return [arg]
+
def expand_glob_expressions(args):
result = [args[0]]
for arg in args[1:]:
- if isinstance(arg, GlobItem):
- result.extend(arg.resolve())
- else:
- result.append(arg)
+ result.extend(expand_glob(arg))
return result
def quote_windows_command(seq):
@@ -323,15 +325,19 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
else:
if r[2] is None:
redir_filename = None
- if kAvoidDevNull and r[0] == '/dev/null':
+ name = expand_glob(r[0])
+ if len(name) != 1:
+ raise InternalShellError(j,"Unsupported: glob in redirect expanded to multiple files")
+ name = name[0]
+ if kAvoidDevNull and name == '/dev/null':
r[2] = tempfile.TemporaryFile(mode=r[1])
- elif kIsWindows and r[0] == '/dev/tty':
+ elif kIsWindows and name == '/dev/tty':
# Simulate /dev/tty on Windows.
# "CON" is a special filename for the console.
r[2] = open("CON", r[1])
else:
# Make sure relative paths are relative to the cwd.
- redir_filename = os.path.join(cmd_shenv.cwd, r[0])
+ redir_filename = os.path.join(cmd_shenv.cwd, name)
r[2] = open(redir_filename, r[1])
# Workaround a Win32 and/or subprocess bug when appending.
#
OpenPOWER on IntegriCloud