From 71d5a2540a98c81f5bcaeb48805e0e2881f530ef Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:01:22 +0000 Subject: Vendor import of llvm trunk r300422: https://llvm.org/svn/llvm-project/llvm/trunk@300422 --- utils/lit/tests/unit/TestRunner.py | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'utils/lit/tests/unit/TestRunner.py') diff --git a/utils/lit/tests/unit/TestRunner.py b/utils/lit/tests/unit/TestRunner.py index ff11834fed7e..79cc10f7e14d 100644 --- a/utils/lit/tests/unit/TestRunner.py +++ b/utils/lit/tests/unit/TestRunner.py @@ -89,7 +89,7 @@ class TestIntegratedTestKeywordParser(unittest.TestCase): parsers = self.make_parsers() self.parse_test(parsers) list_parser = self.get_parser(parsers, 'MY_LIST:') - self.assertItemsEqual(list_parser.getValue(), + self.assertEqual(list_parser.getValue(), ['one', 'two', 'three', 'four']) def test_commands(self): @@ -106,8 +106,65 @@ class TestIntegratedTestKeywordParser(unittest.TestCase): self.parse_test(parsers) custom_parser = self.get_parser(parsers, 'MY_CUSTOM:') value = custom_parser.getValue() - self.assertItemsEqual(value, ['a', 'b', 'c']) + self.assertEqual(value, ['a', 'b', 'c']) + 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") + except ValueError as e: + pass + except BaseException as e: + self.fail("TAG_NO_SUFFIX raised the wrong exception: %r" % e) + + try: + IntegratedTestKeywordParser("TAG_WITH_COLON:", ParserKind.TAG), + self.fail("TAG_WITH_COLON: failed to raise an exception") + except ValueError as e: + pass + except BaseException as e: + self.fail("TAG_WITH_COLON: raised the wrong exception: %r" % e) + + try: + IntegratedTestKeywordParser("LIST_WITH_DOT.", ParserKind.LIST), + self.fail("LIST_WITH_DOT. failed to raise an exception") + except ValueError as e: + pass + except BaseException as e: + self.fail("LIST_WITH_DOT. raised the wrong exception: %r" % e) + + try: + IntegratedTestKeywordParser("CUSTOM_NO_SUFFIX", + ParserKind.CUSTOM, custom_parse), + self.fail("CUSTOM_NO_SUFFIX failed to raise an exception") + except ValueError as e: + pass + except BaseException as e: + self.fail("CUSTOM_NO_SUFFIX raised the wrong exception: %r" % e) + + # Both '.' and ':' are allowed for CUSTOM keywords. + try: + IntegratedTestKeywordParser("CUSTOM_WITH_DOT.", + ParserKind.CUSTOM, custom_parse), + except BaseException as e: + self.fail("CUSTOM_WITH_DOT. raised an exception: %r" % e) + try: + IntegratedTestKeywordParser("CUSTOM_WITH_COLON:", + ParserKind.CUSTOM, custom_parse), + except BaseException as e: + self.fail("CUSTOM_WITH_COLON: raised an exception: %r" % e) + + try: + IntegratedTestKeywordParser("CUSTOM_NO_PARSER:", + ParserKind.CUSTOM), + self.fail("CUSTOM_NO_PARSER: failed to raise an exception") + except ValueError as e: + pass + except BaseException as e: + self.fail("CUSTOM_NO_PARSER: raised the wrong exception: %r" % e) if __name__ == '__main__': TestIntegratedTestKeywordParser.load_keyword_parser_lit_tests() -- cgit v1.2.3