llvm.org GIT mirror llvm / bda64db
make XFAIL, REQUIRES, and UNSUPPORTED support multi-line expressions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351668 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Fiselier 6 months ago
3 changed file(s) with 44 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
14001400 @staticmethod
14011401 def _handleBooleanExpr(line_number, line, output):
14021402 """A parser for BOOLEAN_EXPR type keywords"""
1403 parts = [s.strip() for s in line.split(',') if s.strip() != '']
1404 if output and output[-1][-1] == '\\':
1405 output[-1] = output[-1][:-1] + parts[0]
1406 del parts[0]
14031407 if output is None:
14041408 output = []
1405 output.extend([s.strip() for s in line.split(',')])
1409 output.extend(parts)
14061410 # Evaluate each expression to verify syntax.
14071411 # We don't want any results, just the raised ValueError.
14081412 for s in output:
1409 if s != '*':
1413 if s != '*' and not s.endswith('\\'):
14101414 BooleanExpression.evaluate(s, [])
14111415 return output
14121416
14851489 return lit.Test.Result(Test.UNRESOLVED,
14861490 "Test has unterminated run lines (with '\\')")
14871491
1492 # Check boolean expressions for unterminated lines.
1493 for key in keyword_parsers:
1494 kp = keyword_parsers[key]
1495 if kp.kind != ParserKind.BOOLEAN_EXPR:
1496 continue
1497 value = kp.getValue()
1498 if value and value[-1][-1] == '\\':
1499 raise ValueError("Test has unterminated %s lines (with '\\')" % key)
1500
14881501 # Enforce REQUIRES:
14891502 missing_required_features = test.getMissingRequiredFeatures()
14901503 if missing_required_features:
88 //
99 // MY_CUSTOM: a b c
1010 //
11 // MY_BOOL: a && (\
12 // MY_BOOL: b)
13 // MY_BOOL: d
14 //
15 // MY_BOOL_UNTERMINATED: a \
16 //
1117 // END.
1218 // MY_LIST: five
88 import tempfile
99
1010 import lit
11 import lit.Test as Test
1112 from lit.TestRunner import ParserKind, IntegratedTestKeywordParser, \
1213 parseIntegratedTestScript
1314
5657 IntegratedTestKeywordParser("MY_TAG.", ParserKind.TAG),
5758 IntegratedTestKeywordParser("MY_DNE_TAG.", ParserKind.TAG),
5859 IntegratedTestKeywordParser("MY_LIST:", ParserKind.LIST),
60 IntegratedTestKeywordParser("MY_BOOL:", ParserKind.BOOLEAN_EXPR),
5961 IntegratedTestKeywordParser("MY_RUN:", ParserKind.COMMAND),
6062 IntegratedTestKeywordParser("MY_CUSTOM:", ParserKind.CUSTOM,
61 custom_parse)
63 custom_parse),
64
6265 ]
6366
6467 @staticmethod
100103 self.assertEqual(len(value), 2) # there are only two run lines
101104 self.assertEqual(value[0].strip(), "%dbg(MY_RUN: at line 4) baz")
102105 self.assertEqual(value[1].strip(), "%dbg(MY_RUN: at line 7) foo bar")
106
107 def test_boolean(self):
108 parsers = self.make_parsers()
109 self.parse_test(parsers)
110 bool_parser = self.get_parser(parsers, 'MY_BOOL:')
111 value = bool_parser.getValue()
112 self.assertEqual(len(value), 2) # there are only two run lines
113 self.assertEqual(value[0].strip(), "a && (b)")
114 self.assertEqual(value[1].strip(), "d")
115
116 def test_boolean_unterminated(self):
117 parsers = self.make_parsers() + \
118 [IntegratedTestKeywordParser("MY_BOOL_UNTERMINATED:", ParserKind.BOOLEAN_EXPR)]
119 try:
120 self.parse_test(parsers)
121 self.fail('expected exception')
122 except ValueError as e:
123 self.assertIn("Test has unterminated MY_BOOL_UNTERMINATED: lines", str(e))
124
103125
104126 def test_custom(self):
105127 parsers = self.make_parsers()