Skip to content

Commit 0af8eb5

Browse files
committed
[utils] add more debug logs to update-verify-tests (NFCi)
1 parent f083c4b commit 0af8eb5

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

utils/update_verify_tests/core.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,10 @@ def update_test_file(filename, diag_errors, prefix, updated_test_files):
538538

539539
expansion_context = []
540540
for line in lines:
541+
dprint(f"parsing line {line}")
541542
diag = parse_diag(line, filename, prefix)
542543
if diag:
544+
dprint(f" parsed diag {diag.render()}")
543545
line.diag = diag
544546
if expansion_context:
545547
diag.parent = expansion_context[-1]
@@ -549,6 +551,8 @@ def update_test_file(filename, diag_errors, prefix, updated_test_files):
549551
expansion_context.append(diag)
550552
elif diag.category == "closing":
551553
expansion_context.pop()
554+
else:
555+
dprint(f" no diag")
552556

553557
fold_expansions(lines)
554558
update_lines(diag_errors, lines, orig_lines, prefix, filename, None)
@@ -682,15 +686,20 @@ def check_expectations(tool_output, prefix):
682686
i = 0
683687
while i < len(tool_output):
684688
line = tool_output[i].strip()
689+
extra_lines = []
685690

686691
curr = []
687692
if not "error:" in line:
688-
pass
693+
dprint(f"ignored line: {line.strip()}")
694+
if m := diag_expansion_note_re.match(line.strip()):
695+
raise KnownException(f"unexpected 'nested' note found without preceding diagnostic: '{line.strip()}'")
689696
elif m := diag_error_re.match(line):
697+
dprint(f"diag not found: {line.strip()}")
698+
extra_lines = tool_output[i+1:i+3]
699+
dprint(f"extra lines: {extra_lines}")
690700
diag = parse_diag(
691-
Line(tool_output[i + 1], int(m.group(2))), m.group(1), prefix
701+
Line(extra_lines[0], int(m.group(2))), m.group(1), prefix
692702
)
693-
i += 2
694703
curr.append(
695704
NotFoundDiag(
696705
m.group(1),
@@ -702,6 +711,9 @@ def check_expectations(tool_output, prefix):
702711
)
703712
)
704713
elif m := diag_error_re2.match(line):
714+
dprint(f"unexpected diag: {line.strip()}")
715+
extra_lines = tool_output[i+1:i+3]
716+
dprint(f"extra lines: {extra_lines}")
705717
curr.append(
706718
ExtraDiag(
707719
m.group(1),
@@ -712,14 +724,16 @@ def check_expectations(tool_output, prefix):
712724
prefix,
713725
)
714726
)
715-
i += 2
716727
# Create two mirroring mismatches when the compiler reports that the category or diagnostic is incorrect.
717728
# This makes it easier to handle cases where the same diagnostic is mentioned both in an incorrect message/category
718729
# diagnostic, as well as in an error not produced diagnostic. This can happen for things like 'expected-error 2{{foo}}'
719730
# if only one diagnostic is emitted on that line, and the content of that diagnostic is actually 'bar'.
720731
elif m := diag_error_re3.match(line):
732+
dprint(f"wrong diag message: {line.strip()}")
733+
extra_lines = tool_output[i+1:i+4]
734+
dprint(f"extra lines: {extra_lines}")
721735
diag = parse_diag(
722-
Line(tool_output[i + 1], int(m.group(2))), m.group(1), prefix
736+
Line(extra_lines[0], int(m.group(2))), m.group(1), prefix
723737
)
724738
curr.append(
725739
NotFoundDiag(
@@ -737,17 +751,19 @@ def check_expectations(tool_output, prefix):
737751
diag.absolute_target(),
738752
int(m.group(3)),
739753
diag.category,
740-
tool_output[i + 3].strip(),
754+
extra_lines[2].strip(),
741755
diag.prefix,
742756
)
743757
)
744-
i += 3
745758
elif m := diag_error_re4.match(line):
759+
dprint(f"wrong diag kind: {line.strip()}")
760+
extra_lines = tool_output[i+1:i+4]
761+
dprint(f"extra lines: {extra_lines}")
746762
diag = parse_diag(
747-
Line(tool_output[i + 1], int(m.group(2))), m.group(1), prefix
763+
Line(extra_lines[0], int(m.group(2))), m.group(1), prefix
748764
)
749765
assert diag.category == m.group(4)
750-
assert tool_output[i + 3].strip() == m.group(5)
766+
assert extra_lines[2].strip() == m.group(5)
751767
curr.append(
752768
NotFoundDiag(
753769
m.group(1),
@@ -768,22 +784,22 @@ def check_expectations(tool_output, prefix):
768784
diag.prefix,
769785
)
770786
)
771-
i += 3
772787
else:
773-
dprint("no match")
774-
dprint(line.strip())
775-
i += 1
788+
dprint(f"no match: {line.strip()}")
789+
i += 1 + len(extra_lines)
776790

777791
while (
778792
curr
779793
and i < len(tool_output)
780794
and (m := diag_expansion_note_re.match(tool_output[i].strip()))
781795
):
796+
nested_note_lines = tool_output[i:i+3]
797+
dprint(f"nested note lines: {nested_note_lines}")
782798
curr = [
783799
NestedDiag(m.group(1), int(m.group(2)), int(m.group(3)), e)
784800
for e in curr
785801
]
786-
i += 3
802+
i += len(nested_note_lines)
787803
top_level.extend(curr)
788804

789805
except KnownException as e:

0 commit comments

Comments
 (0)