[llvm] r328603 - Revert "Revert "[lit] Generalized /dev/null support on Windows.""
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 26 18:39:17 PDT 2018
Author: mtrofin
Date: Mon Mar 26 18:39:17 2018
New Revision: 328603
URL: http://llvm.org/viewvc/llvm-project?rev=328603&view=rev
Log:
Revert "Revert "[lit] Generalized /dev/null support on Windows.""
Summary:
This reverts commit r328596.
Checking if the arguments are strings before testing if they contain "/dev/null".
Reviewers: rnk
Reviewed By: rnk
Subscribers: delcypher, llvm-commits
Differential Revision: https://reviews.llvm.org/D44914
Added:
llvm/trunk/utils/lit/tests/Inputs/shtest-shell/check_args.py
llvm/trunk/utils/lit/tests/Inputs/shtest-shell/dev-null.txt
Modified:
llvm/trunk/test/tools/llvm-profdata/invalid-profdata.test
llvm/trunk/utils/lit/lit/TestRunner.py
Modified: llvm/trunk/test/tools/llvm-profdata/invalid-profdata.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/invalid-profdata.test?rev=328603&r1=328602&r2=328603&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/invalid-profdata.test (original)
+++ llvm/trunk/test/tools/llvm-profdata/invalid-profdata.test Mon Mar 26 18:39:17 2018
@@ -20,7 +20,7 @@ RUN: echo "f2:0"
RUN: echo "1" >> %t.input
RUN: echo ":10" >> %t.input
-RUN: not llvm-profdata merge %t.input -text -o /dev/null 2>&1 | FileCheck %s --check-prefix=BROKEN
+RUN: not llvm-profdata merge %t.input -text -output=/dev/null 2>&1 | FileCheck %s --check-prefix=BROKEN
BROKEN: Malformed instrumentation profile data
RUN: echo ":ir" > %t.input
Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=328603&r1=328602&r2=328603&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Mon Mar 26 18:39:17 2018
@@ -36,6 +36,7 @@ kUseCloseFDs = not kIsWindows
# Use temporary files to replace /dev/null on Windows.
kAvoidDevNull = kIsWindows
+kDevNull = "/dev/null"
class ShellEnvironment(object):
@@ -626,7 +627,7 @@ def processRedirects(cmd, stdin_source,
raise InternalShellError(cmd, "Unsupported: glob in "
"redirect expanded to multiple files")
name = name[0]
- if kAvoidDevNull and name == '/dev/null':
+ if kAvoidDevNull and name == kDevNull:
fd = tempfile.TemporaryFile(mode=mode)
elif kIsWindows and name == '/dev/tty':
# Simulate /dev/tty on Windows.
@@ -797,11 +798,11 @@ def _executeShCmd(cmd, shenv, results, t
# Replace uses of /dev/null with temporary files.
if kAvoidDevNull:
for i,arg in enumerate(args):
- if arg == "/dev/null":
+ if isinstance(arg, basestring) and kDevNull in arg:
f = tempfile.NamedTemporaryFile(delete=False)
f.close()
named_temp_files.append(f.name)
- args[i] = f.name
+ args[i] = arg.replace(kDevNull, f.name)
# Expand all glob expressions
args = expand_glob_expressions(args, cmd_shenv.cwd)
Added: llvm/trunk/utils/lit/tests/Inputs/shtest-shell/check_args.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-shell/check_args.py?rev=328603&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-shell/check_args.py (added)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-shell/check_args.py Mon Mar 26 18:39:17 2018
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+import argparse
+import platform
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--my_arg", "-a")
+
+args = parser.parse_args()
+
+answer = (platform.system() == "Windows" and
+ args.my_arg == "/dev/null" and "ERROR") or "OK"
+
+print(answer)
Added: llvm/trunk/utils/lit/tests/Inputs/shtest-shell/dev-null.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-shell/dev-null.txt?rev=328603&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-shell/dev-null.txt (added)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-shell/dev-null.txt Mon Mar 26 18:39:17 2018
@@ -0,0 +1,14 @@
+# Check handling of /dev/null in command line options
+# On windows, it should be redirected to a temp file.
+#
+# RUN: "%{python}" %S/check_args.py --my_arg /dev/null | FileCheck %s --check-prefix=CHECK1
+# CHECK1: OK
+
+# RUN: "%{python}" %S/check_args.py --my_arg=/dev/null | FileCheck %s --check-prefix=CHECK2
+# CHECK2: OK
+
+# RUN: "%{python}" %S/check_args.py -a /dev/null | FileCheck %s --check-prefix=CHECK3
+# CHECK3: OK
+
+# RUN: "%{python}" %S/check_args.py -a=/dev/null | FileCheck %s --check-prefix=CHECK4
+# CHECK4: OK
More information about the llvm-commits
mailing list