Skip to content

Commit 759ffba

Browse files
committed
adapt testcase evaluation and reporting
Signed-off-by: Matthias Büchse <[email protected]>
1 parent d8e71de commit 759ffba

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

Tests/scs-compliance-check.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,19 @@ def run_suite(suite: TestSuite, runner: CheckRunner):
282282
def print_report(subject: str, suite: TestSuite, targets: dict, results: dict, verbose=False):
283283
print(f"{subject} {suite.name}:")
284284
for tname, target_spec in targets.items():
285-
failed, missing, passed = suite.select(tname, target_spec).eval_buckets(results)
286-
verdict = 'FAIL' if failed else 'TENTATIVE pass' if missing else 'PASS'
285+
by_value = suite.select(tname, target_spec).eval_buckets(results)
286+
missing, failed, aborted, passed = by_value[None], by_value[-1], by_value[0], by_value[1]
287+
verdict = 'FAIL' if failed or aborted else 'TENTATIVE pass' if missing else 'PASS'
287288
summary_parts = [f"{len(passed)} passed"]
288289
if failed:
289290
summary_parts.append(f"{len(failed)} failed")
291+
if aborted:
292+
summary_parts.append(f"{len(aborted)} aborted")
290293
if missing:
291294
summary_parts.append(f"{len(missing)} missing")
292295
verdict += f" ({', '.join(summary_parts)})"
293296
print(f"- {tname}: {verdict}")
294-
reportcateg = [(failed, 'FAILED'), (missing, 'MISSING')]
297+
reportcateg = [(failed, 'FAILED'), (aborted, 'ABORTED'), (missing, 'MISSING')]
295298
if verbose:
296299
reportcateg.append((passed, 'PASSED'))
297300
for offenders, category in reportcateg:

Tests/scs_cert_lib.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
'testcases': ('lifetime', 'id', 'description', 'tags'),
2424
'include': ('ref', 'parameters'),
2525
}
26-
# The canonical result values are -1, 0, and 1, for FAIL, MISS (or DNF), and PASS, respectively;
27-
# these concrete numbers are important because we do rely on their ordering. Note that MISS/DNF should
28-
# not be reported because it is tantamount to a result being absent. (Therefore the NIL_RESULT default
29-
# value below.)
30-
TESTCASE_VERDICTS = {'PASS': 1, 'FAIL': -1}
31-
NIL_RESULT = {'result': 0}
26+
# The canonical result values are -1, 0, and 1, for FAIL, ABORT, and PASS, respectively;
27+
# -- in addition, None is used to encode a missing value, but must not be included in a formal report! --
28+
# these concrete numbers are important because we do rely on their ordering.
29+
TESTCASE_VERDICTS = {'PASS': 1, 'ABORT': 0, 'FAIL': -1}
3230

3331

3432
def _check_keywords(ctx, d, keywords=KEYWORDS):
@@ -208,18 +206,26 @@ def select(self, name, selectors):
208206
suite.include_testcases([tc for tc in self.testcases if test_selectors(selectors, tc['tags'])])
209207
return suite
210208

211-
def eval_buckets(self, results) -> tuple[list[dict], list[dict], list[dict]]:
212-
"""returns lists of (failed, missing, passed) test cases"""
209+
def eval_buckets(self, results) -> dict:
210+
"""
211+
returns buckets of test cases by means of a mapping
212+
213+
None: list of missing testcases
214+
-1: list of failed testcases
215+
0: list of aborted testcases
216+
1: list of passed testcases
217+
"""
213218
by_value = defaultdict(list)
214219
for testcase in self.testcases:
215-
value = results.get(testcase['id'], NIL_RESULT).get('result', 0)
220+
value = results.get(testcase['id'], {}).get('result')
216221
by_value[value].append(testcase)
217-
return by_value[-1], by_value[0], by_value[1]
222+
return by_value
218223

219224
def evaluate(self, results) -> int:
220225
"""returns overall result"""
221226
return min([
222-
results.get(testcase['id'], NIL_RESULT).get('result', 0)
227+
# here, we treat None (MISSING) as 0 (ABORT)
228+
results.get(testcase['id'], {}).get('result') or 0
223229
for testcase in self.testcases
224230
], default=0)
225231

0 commit comments

Comments
 (0)