[PATCH] D44771: [lit] Test /dev/null support on Windows.
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 23 12:04:27 PDT 2018
mtrofin updated this revision to Diff 139633.
mtrofin added a comment.
Revert "[llvm-profdata] Use "-o /dev/null" in invalid-profdata.test"
Repository:
rL LLVM
https://reviews.llvm.org/D44771
Files:
test/tools/llvm-profdata/invalid-profdata.test
utils/lit/lit/TestRunner.py
utils/lit/tests/Inputs/testrunner-custom-parsers/test.txt
utils/lit/tests/unit/TestRunner.py
Index: utils/lit/tests/unit/TestRunner.py
===================================================================
--- utils/lit/tests/unit/TestRunner.py
+++ utils/lit/tests/unit/TestRunner.py
@@ -98,9 +98,15 @@
self.parse_test(parsers)
cmd_parser = self.get_parser(parsers, 'MY_RUN:')
value = cmd_parser.getValue()
- self.assertEqual(len(value), 2) # there are only two run lines
+ self.assertEqual(len(value), 4) # there are four run lines
self.assertEqual(value[0].strip(), 'baz')
self.assertEqual(value[1].strip(), 'foo bar')
+ if platform.system() != 'Windows':
+ self.assertEqual(value[2].strip(), 'command -o /dev/null')
+ self.assertEqual(value[3].strip(), 'command -output=/dev/null')
+ else:
+ self.assertFalse('/dev/null' in value[2].strip())
+ self.assertFalse('/dev/null' in value[3].strip())
def test_custom(self):
parsers = self.make_parsers()
@@ -112,7 +118,7 @@
def test_bad_keywords(self):
def custom_parse(line_number, line, output):
return output
-
+
try:
IntegratedTestKeywordParser("TAG_NO_SUFFIX", ParserKind.TAG),
self.fail("TAG_NO_SUFFIX failed to raise an exception")
Index: utils/lit/tests/Inputs/testrunner-custom-parsers/test.txt
===================================================================
--- utils/lit/tests/Inputs/testrunner-custom-parsers/test.txt
+++ utils/lit/tests/Inputs/testrunner-custom-parsers/test.txt
@@ -6,6 +6,8 @@
// MY_LIST: three, four
// MY_RUN: foo \
// MY_RUN: bar
+// MY_RUN: command -o /dev/null
+// MY_RUN: command -output=/dev/null
//
// MY_CUSTOM: a b c
//
Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -36,6 +36,7 @@
# Use temporary files to replace /dev/null on Windows.
kAvoidDevNull = kIsWindows
+kDevNull = "/dev/null"
class ShellEnvironment(object):
@@ -626,7 +627,7 @@
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.
@@ -793,11 +794,11 @@
# Replace uses of /dev/null with temporary files.
if kAvoidDevNull:
for i,arg in enumerate(args):
- if arg == "/dev/null":
+ if 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)
Index: test/tools/llvm-profdata/invalid-profdata.test
===================================================================
--- test/tools/llvm-profdata/invalid-profdata.test
+++ test/tools/llvm-profdata/invalid-profdata.test
@@ -20,7 +20,7 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44771.139633.patch
Type: text/x-patch
Size: 3759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180323/510da12a/attachment.bin>
More information about the llvm-commits
mailing list