Skip to content

Commit 32e6649

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
1 parent a44c4d8 commit 32e6649

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

validate.py

Lines changed: 7 additions & 6 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.
@@ -56,7 +57,7 @@ def __init__(self):
5657
self.spaceafterno_in_effect = False
5758
# Error counter by error type. Key: error type; value: error count.
5859
# Incremented in Incident.report().
59-
self.error_counter = {}
60+
self.error_counter = defaultdict(list)
6061
# Set of detailed error explanations that have been printed so far.
6162
# Each explanation will be printed only once. Typically, an explanation
6263
# can be identified by test id + language code. Nevertheless, we put
@@ -638,12 +639,12 @@ def __init__(self, state, args, level=None, testclass=None, testid=None, message
638639

639640
def report(self):
640641
# Even if we should be quiet, at least count the error.
641-
self.state.error_counter[self.testclass] = self.state.error_counter.get(self.testclass, 0)+1
642+
self.state.error_counter[self.testclass].append(self)
642643
if self.args.quiet:
643644
return
644645
# Suppress error messages of a type of which we have seen too many.
645-
if self.args.max_err > 0 and self.state.error_counter[self.testclass] > self.args.max_err:
646-
if self.state.error_counter[self.testclass] == self.args.max_err + 1:
646+
if self.args.max_err > 0 and len(self.state.error_counter[self.testclass]) > self.args.max_err:
647+
if len(self.state.error_counter[self.testclass]) == self.args.max_err + 1:
647648
print(f'...suppressing further errors regarding {self.testclass}', file=sys.stderr)
648649
return # suppressed
649650
# If we are here, the error message should really be printed.
@@ -4455,10 +4456,10 @@ def main():
44554456
errors = 'Warnings'
44564457
else:
44574458
errors = k+' errors'
4458-
nerror += v
4459+
nerror += len(v)
44594460
passed = False
44604461
if not args.quiet:
4461-
print(f'{errors}: {v}', file=sys.stderr)
4462+
print(f'{errors}: {len(v)}', file=sys.stderr)
44624463
# Print the final verdict and exit.
44634464
if passed:
44644465
if not args.quiet:

0 commit comments

Comments
 (0)