On Thu, Feb 27, 2020 at 4:09 PM Heidi Fahim heidifahim@google.com wrote:
-TAP_ENTRIES = re.compile(r'^(TAP|\t?ok|\t?not ok|\t?[0-9]+..[0-9]+|\t?#).*$') +TAP_ENTRIES = re.compile(r'(TAP|\t?ok|\t?not ok|\t?[0-9]+..[0-9]+|\t# .*?:.*?).*$')
Since you now strip off prefixes using length, does the old TAP regex no longer work?
Using old regex (i.e. match instead of search) still works - do you prefer this be reverted where possible or be changed to search? Search is a little more relaxed when it comes to alignment of the TAP output (i.e. some lines could have extra leading whitespaces), but right now is not necessary.
I would prefer keeping the old regexes. It makes the change smaller. I also would prefer to not relax the alignment if we don't need to.
def consume_non_diagnositic(lines: List[str]) -> None:
while lines and not TAP_ENTRIES.match(lines[0]):
while lines and not TAP_ENTRIES.search(lines[0]): lines.pop(0)
def save_non_diagnositic(lines: List[str], test_case: TestCase) -> None:
while lines and not TAP_ENTRIES.match(lines[0]):
while lines and not TAP_ENTRIES.search(lines[0]): test_case.log.append(lines[0]) lines.pop(0)
OkNotOkResult = namedtuple('OkNotOkResult', ['is_ok','description', 'text'])
[...]
@@ -234,11 +234,11 @@ def parse_test_suite(lines: List[str]) -> TestSuite: expected_test_case_num = parse_subtest_plan(lines) if not expected_test_case_num: return None
test_case = parse_test_case(lines, expected_test_case_num > 0)
expected_test_case_num -= 1
while test_case:
while expected_test_case_num > 0:
test_case = parse_test_case(lines)
if not test_case:
break test_suite.cases.append(test_case)
test_case = parse_test_case(lines, expected_test_case_num > 0) expected_test_case_num -= 1
Do we use this variable anymore?
Yes, this decides whether we are expecting another test case or if we've completed the test suite
Ah gotcha. Sorry, I am not sure how I missed that.
if parse_ok_not_ok_test_suite(lines, test_suite): test_suite.status = bubble_up_test_case_errors(test_suite)
@@ -250,7 +250,7 @@ def parse_test_suite(lines: List[str]) -> TestSuite: print('failed to parse end of suite' + lines[0]) return None
-TAP_HEADER = re.compile(r'^TAP version 14$') +TAP_HEADER = re.compile(r'TAP version 14$')
def parse_tap_header(lines: List[str]) -> bool: consume_non_diagnositic(lines)
Cheers!