Add option to output failures only

This commit is contained in:
2022-10-11 07:08:50 +10:30
parent 10ff26b17f
commit 9fe3171505
2 changed files with 10 additions and 5 deletions

View File

@@ -2,8 +2,9 @@ import json
class CheckReporter:
def __init__(self):
def __init__(self, output_passes):
self.checks = list()
self.output_passes = output_passes
def append(self, check):
self.checks.append(check)
@@ -35,7 +36,7 @@ class JSONReporter(CheckReporter):
list(
map(
lambda check: JSONReporter.__make_check_serialisable(check),
self.checks,
self.checks if self.output_passes else self.failed(),
)
),
indent=4,
@@ -45,6 +46,8 @@ class JSONReporter(CheckReporter):
class DefaultReporter(CheckReporter):
def append(self, check):
super().append(check)
if check.check_successful and not self.output_passes:
return
result = f"[{'PASS' if check.check_successful else 'FAIL'}] Check host {check.hostname}"
if check.debug:
result += f" - {check.debug}"