llvm.org GIT mirror llvm / 8bd0ee7
Revert r330755 "[lit] Report line number for failed RUN command" It is causing many tests to fail on Windows buildbots: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10211 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330848 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 1 year, 5 months ago
16 changed file(s) with 16 addition(s) and 155 deletion(s). Raw diff Collapse all Expand all
8484 Echo all commands to stdout, as they are being executed.
8585 This can be valuable for debugging test failures, as the last echoed command
8686 will be the one which has failed.
87 To help you find the source RUN line, :program:`lit` inserts a no-op ``:``
88 command with argument ``'RUN: at line N'`` before each command pipeline.
8987 This option implies ``--verbose``.
9088
9189 .. option:: -a, --show-all
788788 results.append(cmdResult)
789789 return cmdResult.exitCode
790790
791 if cmd.commands[0].args[0] == ':':
792 if len(cmd.commands) != 1:
793 raise InternalShellError(cmd.commands[0], "Unsupported: ':' "
794 "cannot be part of a pipeline")
795 results.append(ShellCommandResult(cmd.commands[0], '', '', 0, False))
796 return 0;
797
798791 procs = []
799792 default_stdin = subprocess.PIPE
800793 stderrTempFiles = []
13241317 def parseLine(self, line_number, line):
13251318 try:
13261319 self.parsed_lines += [(line_number, line)]
1327 self.value = self.parser(line_number, line, self.value,
1328 self.keyword)
1320 self.value = self.parser(line_number, line, self.value)
13291321 except ValueError as e:
13301322 raise ValueError(str(e) + ("\nin %s directive on test line %d" %
13311323 (self.keyword, line_number)))
13341326 return self.value
13351327
13361328 @staticmethod
1337 def _handleTag(line_number, line, output, keyword):
1329 def _handleTag(line_number, line, output):
13381330 """A helper for parsing TAG type keywords"""
13391331 return (not line.strip() or output)
13401332
13411333 @staticmethod
1342 def _handleCommand(line_number, line, output, keyword):
1334 def _handleCommand(line_number, line, output):
13431335 """A helper for parsing COMMAND type keywords"""
13441336 # Trim trailing whitespace.
13451337 line = line.rstrip()
13581350 else:
13591351 if output is None:
13601352 output = []
1361 line = ": '{keyword} at line {line}'; {real_command}".format(
1362 keyword=keyword,
1363 line=line_number,
1364 real_command=line)
13651353 output.append(line)
13661354 return output
13671355
13681356 @staticmethod
1369 def _handleList(line_number, line, output, keyword):
1357 def _handleList(line_number, line, output):
13701358 """A parser for LIST type keywords"""
13711359 if output is None:
13721360 output = []
13741362 return output
13751363
13761364 @staticmethod
1377 def _handleBooleanExpr(line_number, line, output, keyword):
1365 def _handleBooleanExpr(line_number, line, output):
13781366 """A parser for BOOLEAN_EXPR type keywords"""
13791367 if output is None:
13801368 output = []
13871375 return output
13881376
13891377 @staticmethod
1390 def _handleRequiresAny(line_number, line, output, keyword):
1378 def _handleRequiresAny(line_number, line, output):
13911379 """A custom parser to transform REQUIRES-ANY: into REQUIRES:"""
13921380
13931381 # Extract the conditions specified in REQUIRES-ANY: as written.
13941382 conditions = []
1395 IntegratedTestKeywordParser._handleList(line_number, line, conditions,
1396 keyword)
1383 IntegratedTestKeywordParser._handleList(line_number, line, conditions)
13971384
13981385 # Output a `REQUIRES: a || b || c` expression in its place.
13991386 expression = ' || '.join(conditions)
1400 IntegratedTestKeywordParser._handleBooleanExpr(line_number, expression,
1401 output, keyword)
1387 IntegratedTestKeywordParser._handleBooleanExpr(line_number,
1388 expression, output)
14021389 return output
14031390
14041391 def parseIntegratedTestScript(test, additional_parsers=[],
+0
-3
utils/lit/tests/Inputs/shtest-run-at-line/external-shell/basic.txt less more
None # RUN: true
1 # RUN: false
2 # RUN: true
+0
-11
utils/lit/tests/Inputs/shtest-run-at-line/external-shell/line-continuation.txt less more
None # RUN: : first line continued \
1 # RUN: to second line
2 # RUN: echo 'foo bar' \
3 # RUN: | FileCheck %s
4 # RUN: echo \
5 # RUN: 'foo baz' \
6 # RUN: | FileCheck %s
7 # RUN: echo 'foo bar' \
8 # RUN: | FileCheck %s
9
10 # CHECK: foo bar
+0
-2
utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg less more
None import lit.formats
1 config.test_format = lit.formats.ShTest(execute_external=True)
+0
-3
utils/lit/tests/Inputs/shtest-run-at-line/internal-shell/basic.txt less more
None # RUN: true
1 # RUN: false
2 # RUN: true
+0
-11
utils/lit/tests/Inputs/shtest-run-at-line/internal-shell/line-continuation.txt less more
None # RUN: : first line continued \
1 # RUN: to second line
2 # RUN: echo 'foo bar' \
3 # RUN: | FileCheck %s
4 # RUN: echo \
5 # RUN: 'foo baz' \
6 # RUN: | FileCheck %s
7 # RUN: echo 'foo bar' \
8 # RUN: | FileCheck %s
9
10 # CHECK: foo bar
+0
-2
utils/lit/tests/Inputs/shtest-run-at-line/internal-shell/lit.local.cfg less more
None import lit.formats
1 config.test_format = lit.formats.ShTest(execute_external=False)
+0
-3
utils/lit/tests/Inputs/shtest-run-at-line/lit.cfg less more
None import lit.formats
1 config.name = 'shtest-run-at-line'
2 config.suffixes = ['.txt']
+0
-3
utils/lit/tests/Inputs/shtest-shell/colon-error.txt less more
None # Check error on an unsupported ":". (cannot be part of a pipeline)
1 #
2 # RUN: : | echo "hello"
77 #
88 # END.
99
10 # CHECK: Failing Tests (27)
10 # CHECK: Failing Tests (26)
1111 # CHECK: Failing Tests (1)
1212 # CHECK: Failing Tests (2)
1313 # CHECK: error: Setting --max-failures to 0 does not have any effect.
3838 #
3939 # CHECK: Command Output (stdout):
4040 # CHECK-NEXT: --
41 # CHECK-NEXT: $ ":" "RUN: at line 1"
4241 # CHECK-NEXT: $ "printf"
4342 # CHECK-NEXT: # command output:
4443 # CHECK-NEXT: line 1: failed test output on stdout
1515 #
1616 # CHECK: Command Output
1717 # CHECK-NEXT: --
18 # CHECK-NEXT: $ ":" "RUN: at line 1"
1918 # CHECK-NEXT: $ "true"
20 # CHECK-NEXT: $ ":" "RUN: at line 2"
2119 # CHECK-NEXT: $ "echo" "hi"
2220 # CHECK-NEXT: # command output:
2321 # CHECK-NEXT: hi
2422 #
25 # CHECK: $ ":" "RUN: at line 3"
26 # CHECK-NEXT: $ "wc" "missing-file"
23 # CHECK: $ "wc" "missing-file"
2724 # CHECK-NEXT: # redirected output from '{{.*(/|\\\\)}}basic.txt.tmp.out':
2825 # CHECK-NEXT: missing-file{{.*}} No such file or directory
2926 # CHECK: note: command had no output on stdout or stderr
+0
-74
utils/lit/tests/shtest-run-at-line.py less more
None # Check that -vv makes the line number of the failing RUN command clear.
1 # (-v is actually sufficient in the case of the internal shell.)
2 #
3 # RUN: not %{lit} -j 1 -vv %{inputs}/shtest-run-at-line > %t.out
4 # RUN: FileCheck --input-file %t.out %s
5 #
6 # END.
7
8
9 # CHECK: Testing: 4 tests
10
11
12 # In the case of the external shell, we check for only RUN lines in stderr in
13 # case some shell implementations format "set -x" output differently.
14
15 # CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/basic.txt
16
17 # CHECK: Script:
18 # CHECK: : 'RUN: at line 1'; true
19 # CHECK-NEXT: : 'RUN: at line 2'; false
20 # CHECK-NEXT: : 'RUN: at line 3'; true
21
22 # CHECK: Command Output (stderr)
23 # CHECK: RUN: at line 1
24 # CHECK: RUN: at line 2
25 # CHECK-NOT: RUN
26
27 # CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/line-continuation.txt
28
29 # CHECK: Script:
30 # CHECK: : 'RUN: at line 1'; : first line continued to second line
31 # CHECK-NEXT: : 'RUN: at line 3'; echo 'foo bar' | FileCheck
32 # CHECK-NEXT: : 'RUN: at line 5'; echo 'foo baz' | FileCheck
33 # CHECK-NEXT: : 'RUN: at line 8'; echo 'foo bar' | FileCheck
34
35 # CHECK: Command Output (stderr)
36 # CHECK: RUN: at line 1
37 # CHECK: RUN: at line 3
38 # CHECK: RUN: at line 5
39 # CHECK-NOT: RUN
40
41
42 # CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/basic.txt
43
44 # CHECK: Script:
45 # CHECK: : 'RUN: at line 1'; true
46 # CHECK-NEXT: : 'RUN: at line 2'; false
47 # CHECK-NEXT: : 'RUN: at line 3'; true
48
49 # CHECK: Command Output (stdout)
50 # CHECK: $ ":" "RUN: at line 1"
51 # CHECK-NEXT: $ "true"
52 # CHECK-NEXT: $ ":" "RUN: at line 2"
53 # CHECK-NEXT: $ "false"
54 # CHECK-NOT: RUN
55
56 # CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/line-continuation.txt
57
58 # CHECK: Script:
59 # CHECK: : 'RUN: at line 1'; : first line continued to second line
60 # CHECK-NEXT: : 'RUN: at line 3'; echo 'foo bar' | FileCheck
61 # CHECK-NEXT: : 'RUN: at line 5'; echo 'foo baz' | FileCheck
62 # CHECK-NEXT: : 'RUN: at line 8'; echo 'foo bar' | FileCheck
63
64 # CHECK: Command Output (stdout)
65 # CHECK: $ ":" "RUN: at line 1"
66 # CHECK-NEXT: $ ":" "first" "line" "continued" "to" "second" "line"
67 # CHECK-NEXT: $ ":" "RUN: at line 3"
68 # CHECK-NEXT: $ "echo" "foo bar"
69 # CHECK-NEXT: $ "FileCheck" "{{.*}}"
70 # CHECK-NEXT: $ ":" "RUN: at line 5"
71 # CHECK-NEXT: $ "echo" "foo baz"
72 # CHECK-NEXT: $ "FileCheck" "{{.*}}"
73 # CHECK-NOT: RUN
2525 # CHECK: error: command failed with exit status: 1
2626 # CHECK: ***
2727
28 # CHECK: FAIL: shtest-shell :: colon-error.txt
29 # CHECK: *** TEST 'shtest-shell :: colon-error.txt' FAILED ***
30 # CHECK: $ ":"
31 # CHECK: # command stderr:
32 # CHECK: Unsupported: ':' cannot be part of a pipeline
33 # CHECK: error: command failed with exit status: 127
34 # CHECK: ***
35
3628 # CHECK: FAIL: shtest-shell :: diff-error-0.txt
3729 # CHECK: *** TEST 'shtest-shell :: diff-error-0.txt' FAILED ***
3830 # CHECK: $ "diff" "diff-error-0.txt" "diff-error-0.txt"
160152 #
161153 # CHECK: FAIL: shtest-shell :: error-1.txt
162154 # CHECK: *** TEST 'shtest-shell :: error-1.txt' FAILED ***
163 # CHECK: shell parser error on: ': \'RUN: at line 3\'; echo "missing quote'
155 # CHECK: shell parser error on: 'echo "missing quote'
164156 # CHECK: ***
165157
166158 # CHECK: FAIL: shtest-shell :: error-2.txt
226218 # CHECK: PASS: shtest-shell :: sequencing-0.txt
227219 # CHECK: XFAIL: shtest-shell :: sequencing-1.txt
228220 # CHECK: PASS: shtest-shell :: valid-shell.txt
229 # CHECK: Failing Tests (27)
221 # CHECK: Failing Tests (26)
4646
4747 @staticmethod
4848 def make_parsers():
49 def custom_parse(line_number, line, output, keyword):
49 def custom_parse(line_number, line, output):
5050 if output is None:
5151 output = []
5252 output += [part for part in line.split(' ') if part.strip()]
9898 cmd_parser = self.get_parser(parsers, 'MY_RUN:')
9999 value = cmd_parser.getValue()
100100 self.assertEqual(len(value), 2) # there are only two run lines
101 self.assertEqual(value[0].strip(), ": 'MY_RUN: at line 4'; baz")
102 self.assertEqual(value[1].strip(), ": 'MY_RUN: at line 7'; foo bar")
101 self.assertEqual(value[0].strip(), 'baz')
102 self.assertEqual(value[1].strip(), 'foo bar')
103103
104104 def test_custom(self):
105105 parsers = self.make_parsers()