Skip to content

Commit 9ad3a82

Browse files
committed
Save the errors in the state, not just the error counts. Makes it easier for a calling program to use the results
Only keep track of --max_err errors, but still count all the errors
1 parent a44c4d8 commit 9ad3a82

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

validate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os.path
88
import argparse
99
import traceback
10+
from collections import defaultdict
1011
# According to https://stackoverflow.com/questions/1832893/python-regex-matching-unicode-properties,
1112
# the regex module has the same API as re but it can check Unicode character properties using \p{}
1213
# as in Perl.
@@ -57,6 +58,9 @@ def __init__(self):
5758
# Error counter by error type. Key: error type; value: error count.
5859
# Incremented in Incident.report().
5960
self.error_counter = {}
61+
# Lists of errors for each type, up to --max_err
62+
# Key: error type; value: a list of the errors
63+
self.error_tracker = defaultdict(list)
6064
# Set of detailed error explanations that have been printed so far.
6165
# Each explanation will be printed only once. Typically, an explanation
6266
# can be identified by test id + language code. Nevertheless, we put
@@ -639,6 +643,8 @@ def __init__(self, state, args, level=None, testclass=None, testid=None, message
639643
def report(self):
640644
# Even if we should be quiet, at least count the error.
641645
self.state.error_counter[self.testclass] = self.state.error_counter.get(self.testclass, 0)+1
646+
if self.args.max_err <= 0 or len(self.state.error_tracker[self.testclass]) < self.args.max_err:
647+
self.state.error_tracker[self.testclass].append(self)
642648
if self.args.quiet:
643649
return
644650
# Suppress error messages of a type of which we have seen too many.

0 commit comments

Comments
 (0)