diff --git a/Scripts/o2_linter.py b/Scripts/o2_linter.py index b0bd050c0c1..1c3350baff9 100644 --- a/Scripts/o2_linter.py +++ b/Scripts/o2_linter.py @@ -162,6 +162,7 @@ class TestSpec(ABC): message = "Test failed" # error message suffixes: "list[str]" = [] # suffixes of files to test per_line = True # Test lines separately one by one. + n_issues = 0 # issue counter def file_matches(self, path: str) -> bool: """Test whether the path matches the pattern for files to test.""" @@ -202,10 +203,12 @@ def run(self, path: str, content) -> bool: continue if not self.test_line(line): passed = False + self.n_issues += 1 print_error(path, i + 1, self.name, self.message) else: passed = self.test_file(path, content) if not passed: + self.n_issues += 1 print_error(path, None, self.name, self.message) return passed @@ -1413,6 +1416,7 @@ def main(): test_names = [t.name for t in tests] # short names of activated tests suffixes = tuple({s for test in tests for s in test.suffixes}) # all suffixes from all enabled tests passed = True # global result of all tests + n_files_bad = {name: 0 for name in test_names} # counter of files with issues # Report overview before running. print(f"Testing {len(args.paths)} files.") @@ -1434,14 +1438,21 @@ def main(): for test in tests: result = test.run(path, content) if not result: + n_files_bad[test.name] += 1 passed = False # print(f"File \"{path}\" {'passed' if result else 'failed'} the test {test.name}.") except IOError: print(f'Failed to open file "{path}".') sys.exit(1) + # Report results per test. + print("\nResults per test") + print("test\tissues\tbad files") + for test in tests: + print(f"{test.name}\t{test.n_issues}\t{n_files_bad[test.name]}") + # Report global result. - title_result = "O2 linter result" + title_result = "\nO2 linter result" if passed: msg_result = "All tests passed." if github_mode: