]>
dreyeck.freedombox.rocks Git - topic-maps.git/blob - scripts/check-report.py
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 slice9
= len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-9'
14 slice8
= slice9
or len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-8'
15 slice7
= slice8
or len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-7'
16 slice6
= slice7
or len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-6'
17 slice5
= slice6
or len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-5'
18 slice4
= slice5
or len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-4'
19 slice1
= slice4
or (len(sys
.argv
) > 2 and sys
.argv
[2] == '--slice-1')
20 assert report
['implemented'] == dict(ctmParsing
=slice1
, tmdmDeserialization
=slice1
, cxtmCanonicalization
=slice4
)
21 assert report
['countsMatchPin'] is True
22 assert report
['correspondence'] == dict(ok
=True, missingInputs
=[], missingBaselines
=[], unmatchedBaselines
=[], duplicateIDs
=[])
23 cases
= report
['cases']
24 assert len(cases
) == report
['counts']['valid'] + report
['counts']['invalid']
25 passes
= 59 if slice9
else 49 if slice8
else 42 if slice7
else 36 if slice6
else 29 if slice5
else 25 if slice4
else int(slice1
)
26 assert report
['statuses'] == {'pass': passes
, 'fail': 0, 'unsupported': 0, 'not-run': len(cases
)-passes
}
27 assert [c
['id'] for c
in cases
] == sorted(c
['id'] for c
in cases
)
28 assert len({c
['id'] for c
in cases
}) == len(cases
)
29 tested
= [c
for c
in cases
if c
['status'] == 'pass']
31 positives
= [c
for c
in tested
if c
['category'] == 'valid']
32 assert len(positives
) == (51 if slice9
else 46 if slice8
else 39 if slice7
else 33 if slice6
else 28 if slice5
else 24) and all(c
['actualOutcome'] == 'cxtm-match' for c
in positives
)
33 untested
= [c
for c
in cases
if c
not in tested
]
34 assert all(c
['status'] == 'not-run' and c
['actualOutcome'] is None and c
['diagnostics'] == [] for c
in untested
)
36 negative
= next(c
for c
in cases
if c
['id'] == 'ctm/invalid/prefix-undefined.ctm')
37 assert negative
['status'] == 'pass' and negative
['actualOutcome'] == 'ctm-rejection'
38 assert len(negative
['diagnostics']) == 1 and 'UNDEFINED-PREFIX' in negative
['diagnostics'][0]
39 assert all(c
['documentIRI'] == 'https://ctm-tests.example.invalid/' + lock
['commit'] + '/' + c
['id'] for c
in cases
)
40 assert sum(c
['category'] == 'valid' for c
in cases
) == report
['counts']['valid']
41 assert sum(c
['category'] == 'invalid' for c
in cases
) == report
['counts']['invalid']
42 assert all(c
['expectedOutcome'] == 'ctm-rejection' and c
['expectedCXTM'] is None for c
in cases
if c
['category'] == 'invalid')
43 assert all(c
['expectedOutcome'] == 'cxtm-equal' and c
['expectedCXTM'].endswith('.ctm.cxtm') for c
in cases
if c
['category'] == 'valid')
44 assert all((root
/'vendor/cxtm'/c
['sourcePathname']).is_file() for c
in cases
)
45 assert all((root
/'vendor/cxtm'/c
['expectedCXTM']).is_file() for c
in cases
if c
['expectedCXTM'])
46 assert len(report
['auxiliaryResources']) == report
['counts']['auxiliary']
47 assert len(report
['baselines']) == report
['counts']['baselines']
48 assert len(report
['infrastructureChecks']) == len(set(report
['infrastructureChecks'])) > 0
49 print('REPORT-JSON-PASS: deterministic schema, draft qualification, case contracts and only warranted imported status changes')
52 for name
, reason
in [('prefix-collision', 'PREFIX-COLLISION'), ('prefix-undefined2', 'UNDEFINED-PREFIX')]:
53 c
= next(c
for c
in cases
if c
['id'] == f
'ctm/invalid/{name}.ctm')
54 assert c
['status'] == 'pass' and c
['actualOutcome'] == 'ctm-rejection'
55 assert len(c
['diagnostics']) == 1 and reason
in c
['diagnostics'][0]
58 for name
, reason
in [('date-invalid-day', 'INVALID-DATE-DAY'), ('date-invalid-month', 'INVALID-DATE-MONTH'),
59 ('date-invalid-year', 'INVALID-DATE-YEAR'), ('date-invalid-year2', 'INVALID-DATE-YEAR'), ('date-invalid-year3', 'INVALID-DATE-YEAR')]:
60 c
= next(c
for c
in cases
if c
['id'] == f
'ctm/invalid/{name}.ctm')
61 assert c
['status'] == 'pass' and c
['actualOutcome'] == 'ctm-rejection'
62 assert len(c
['diagnostics']) == 1 and reason
in c
['diagnostics'][0]