Index: utils/lit/lit/TestRunner.py =================================================================== --- utils/lit/lit/TestRunner.py +++ utils/lit/lit/TestRunner.py @@ -740,6 +740,12 @@ results.append(cmdResult) return cmdResult.exitCode + if cmd.commands[0].args[0] == ':': + if len(cmd.commands) != 1: + raise InternalShellError(cmd.commands[0], "Unsupported: ':' " + "cannot be part of a pipeline") + return 0; + procs = [] default_stdin = subprocess.PIPE stderrTempFiles = [] @@ -1261,7 +1267,8 @@ def parseLine(self, line_number, line): try: self.parsed_lines += [(line_number, line)] - self.value = self.parser(line_number, line, self.value) + self.value = self.parser(line_number, line, self.value, + self.keyword) except ValueError as e: raise ValueError(str(e) + ("\nin %s directive on test line %d" % (self.keyword, line_number))) @@ -1270,12 +1277,12 @@ return self.value @staticmethod - def _handleTag(line_number, line, output): + def _handleTag(line_number, line, output, keyword): """A helper for parsing TAG type keywords""" return (not line.strip() or output) @staticmethod - def _handleCommand(line_number, line, output): + def _handleCommand(line_number, line, output, keyword): """A helper for parsing COMMAND type keywords""" # Trim trailing whitespace. line = line.rstrip() @@ -1294,11 +1301,13 @@ else: if output is None: output = [] + line = ': "' + keyword + '" at line ' + str(line_number) + '; ' + \ + line output.append(line) return output @staticmethod - def _handleList(line_number, line, output): + def _handleList(line_number, line, output, keyword): """A parser for LIST type keywords""" if output is None: output = [] @@ -1306,7 +1315,7 @@ return output @staticmethod - def _handleBooleanExpr(line_number, line, output): + def _handleBooleanExpr(line_number, line, output, keyword): """A parser for BOOLEAN_EXPR type keywords""" if output is None: output = [] @@ -1319,17 +1328,18 @@ return output @staticmethod - def _handleRequiresAny(line_number, line, output): + def _handleRequiresAny(line_number, line, output, keyword): """A custom parser to transform REQUIRES-ANY: into REQUIRES:""" # Extract the conditions specified in REQUIRES-ANY: as written. conditions = [] - IntegratedTestKeywordParser._handleList(line_number, line, conditions) + IntegratedTestKeywordParser._handleList(line_number, line, conditions, + keyword) # Output a `REQUIRES: a || b || c` expression in its place. expression = ' || '.join(conditions) - IntegratedTestKeywordParser._handleBooleanExpr(line_number, - expression, output) + IntegratedTestKeywordParser._handleBooleanExpr(line_number, expression, + output, keyword) return output def parseIntegratedTestScript(test, additional_parsers=[], Index: utils/lit/tests/shtest-shell.py =================================================================== --- utils/lit/tests/shtest-shell.py +++ utils/lit/tests/shtest-shell.py @@ -138,7 +138,7 @@ # # CHECK: FAIL: shtest-shell :: error-1.txt # CHECK: *** TEST 'shtest-shell :: error-1.txt' FAILED *** -# CHECK: shell parser error on: 'echo "missing quote' +# CHECK: shell parser error on: ': "RUN:" at line 3; echo "missing quote' # CHECK: *** # CHECK: FAIL: shtest-shell :: error-2.txt Index: utils/lit/tests/unit/TestRunner.py =================================================================== --- utils/lit/tests/unit/TestRunner.py +++ utils/lit/tests/unit/TestRunner.py @@ -47,7 +47,7 @@ @staticmethod def make_parsers(): - def custom_parse(line_number, line, output): + def custom_parse(line_number, line, output, keyword): if output is None: output = [] output += [part for part in line.split(' ') if part.strip()] @@ -99,8 +99,8 @@ 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(value[0].strip(), 'baz') - self.assertEqual(value[1].strip(), 'foo bar') + self.assertEqual(value[0].strip(), ': "MY_RUN:" at line 4; baz') + self.assertEqual(value[1].strip(), ': "MY_RUN:" at line 7; foo bar') def test_custom(self): parsers = self.make_parsers()