Skip to content

Commit f7bc938

Browse files
committed
Update migration failure count
1 parent 1243b14 commit f7bc938

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

scripts/summarize_parser_test.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Failure:
6060
signature: str = ""
6161
signature_hash: str = ""
6262
source_filename: str = ""
63-
migrated_by: str = "" # name of the migration pattern that made this failure equivalent
63+
migrated_by: list[str] = field(default_factory=list) # names of the migration patterns that made this failure equivalent
6464

6565

6666
@dataclass
@@ -113,16 +113,16 @@ def load_migrations(path: Path) -> list[MigrationPattern]:
113113
return out
114114

115115

116-
def classify_migration(f: Failure, patterns: list[MigrationPattern]) -> str:
117-
"""Return the name (or composite name) of the pattern(s) that equalize the two regions.
116+
def classify_migration(f: Failure, patterns: list[MigrationPattern]) -> list[str]:
117+
"""Return the names of the pattern(s) that equalize the two regions.
118118
119119
Tries each pattern alone first. If none match individually, applies patterns
120-
cumulatively in declaration order; if that equalizes and more than one pattern
121-
actually changed the text, returns their names joined with '+'.
120+
cumulatively in declaration order; if that equalizes, returns the names of
121+
every pattern that actually changed the text.
122122
"""
123123
for p in patterns:
124124
if p.apply(f.test_region) == f.srcml_region:
125-
return p.name
125+
return [p.name]
126126

127127
text = f.test_region
128128
applied: list[str] = []
@@ -131,9 +131,9 @@ def classify_migration(f: Failure, patterns: list[MigrationPattern]) -> str:
131131
if new_text != text:
132132
applied.append(p.name)
133133
text = new_text
134-
if text == f.srcml_region and len(applied) > 1:
135-
return "+".join(applied)
136-
return ""
134+
if text == f.srcml_region:
135+
return applied
136+
return []
137137

138138

139139
@dataclass
@@ -340,7 +340,8 @@ def render_grouped_markdown(report: ParsedReport) -> str:
340340
if migrated:
341341
by_pattern: dict[str, int] = defaultdict(int)
342342
for f in migrated:
343-
by_pattern[f.migrated_by] += 1
343+
for name in f.migrated_by:
344+
by_pattern[name] += 1
344345
lines.append("")
345346
lines.append("## Migrated failures (suppressed)")
346347
lines.append("")

0 commit comments

Comments
 (0)