]>
dreyeck.freedombox.rocks Git - topic-maps.git/blob - scripts/check-report.py
43a1c2d79faaeeba5368f9fe01fb67c9e53e26e2
2 """Check the Lisp-generated JSON with an independent standard-library decoder."""
7 root
= pathlib
.Path(__file__
).resolve().parent
.parent
8 report
= json
.loads(pathlib
.Path(sys
.argv
[1]).read_text())
9 lock
= json
.loads((root
/ 'references/corpus-lock.json').read_text())
10 assert report
['repository'] == lock
['repository'] and report
['commit'] == lock
['commit']
11 assert report
['qualification'] == lock
['draftQualification']
12 assert report
['counts'] == lock
['ctmCounts']
13 slice1
= len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-1'
14 assert report
['implemented'] == dict(ctmParsing
=slice1
, tmdmDeserialization
=slice1
, cxtmCanonicalization
=False)
15 assert report
['countsMatchPin'] is True
16 assert report
['correspondence'] == dict(ok
=True, missingInputs
=[], missingBaselines
=[], unmatchedBaselines
=[], duplicateIDs
=[])
17 cases
= report
['cases']
18 assert len(cases
) == report
['counts']['valid'] + report
['counts']['invalid']
19 assert report
['statuses'] == {'pass': int(slice1
), 'fail': 0, 'unsupported': 0, 'not-run': len(cases
)-int(slice1
)}
20 assert [c
['id'] for c
in cases
] == sorted(c
['id'] for c
in cases
)
21 assert len({c
['id'] for c
in cases
}) == len(cases
)
22 untested
= [c
for c
in cases
if not (slice1
and c
['id'] == 'ctm/invalid/prefix-undefined.ctm')]
23 assert all(c
['status'] == 'not-run' and c
['actualOutcome'] is None and c
['diagnostics'] == [] for c
in untested
)
25 negative
= next(c
for c
in cases
if c
['id'] == 'ctm/invalid/prefix-undefined.ctm')
26 assert negative
['status'] == 'pass' and negative
['actualOutcome'] == 'ctm-rejection'
27 assert len(negative
['diagnostics']) == 1 and 'UNDEFINED-PREFIX' in negative
['diagnostics'][0]
28 assert all(c
['documentIRI'] == 'https://ctm-tests.example.invalid/' + lock
['commit'] + '/' + c
['id'] for c
in cases
)
29 assert sum(c
['category'] == 'valid' for c
in cases
) == report
['counts']['valid']
30 assert sum(c
['category'] == 'invalid' for c
in cases
) == report
['counts']['invalid']
31 assert all(c
['expectedOutcome'] == 'ctm-rejection' and c
['expectedCXTM'] is None for c
in cases
if c
['category'] == 'invalid')
32 assert all(c
['expectedOutcome'] == 'cxtm-equal' and c
['expectedCXTM'].endswith('.ctm.cxtm') for c
in cases
if c
['category'] == 'valid')
33 assert all((root
/'vendor/cxtm'/c
['sourcePathname']).is_file() for c
in cases
)
34 assert all((root
/'vendor/cxtm'/c
['expectedCXTM']).is_file() for c
in cases
if c
['expectedCXTM'])
35 assert len(report
['auxiliaryResources']) == report
['counts']['auxiliary']
36 assert len(report
['baselines']) == report
['counts']['baselines']
37 assert len(report
['infrastructureChecks']) == len(set(report
['infrastructureChecks'])) > 0
38 print('REPORT-JSON-PASS: deterministic schema, draft qualification, case contracts and only warranted imported status changes')