|
7 | 7 | import os.path |
8 | 8 | import argparse |
9 | 9 | import traceback |
| 10 | +from collections import defaultdict |
10 | 11 | # According to https://stackoverflow.com/questions/1832893/python-regex-matching-unicode-properties, |
11 | 12 | # the regex module has the same API as re but it can check Unicode character properties using \p{} |
12 | 13 | # as in Perl. |
@@ -56,7 +57,7 @@ def __init__(self): |
56 | 57 | self.spaceafterno_in_effect = False |
57 | 58 | # Error counter by error type. Key: error type; value: error count. |
58 | 59 | # Incremented in Incident.report(). |
59 | | - self.error_counter = {} |
| 60 | + self.error_counter = defaultdict(list) |
60 | 61 | # Set of detailed error explanations that have been printed so far. |
61 | 62 | # Each explanation will be printed only once. Typically, an explanation |
62 | 63 | # 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 |
638 | 639 |
|
639 | 640 | def report(self): |
640 | 641 | # 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) |
642 | 643 | if self.args.quiet: |
643 | 644 | return |
644 | 645 | # 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: |
647 | 648 | print(f'...suppressing further errors regarding {self.testclass}', file=sys.stderr) |
648 | 649 | return # suppressed |
649 | 650 | # If we are here, the error message should really be printed. |
@@ -4455,10 +4456,10 @@ def main(): |
4455 | 4456 | errors = 'Warnings' |
4456 | 4457 | else: |
4457 | 4458 | errors = k+' errors' |
4458 | | - nerror += v |
| 4459 | + nerror += len(v) |
4459 | 4460 | passed = False |
4460 | 4461 | if not args.quiet: |
4461 | | - print(f'{errors}: {v}', file=sys.stderr) |
| 4462 | + print(f'{errors}: {len(v)}', file=sys.stderr) |
4462 | 4463 | # Print the final verdict and exit. |
4463 | 4464 | if passed: |
4464 | 4465 | if not args.quiet: |
|
0 commit comments