]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-20j/observations.lisp
Verify CTM/XTM semantic equivalence through TMDM and CXTM (Slice 22F)
[topic-maps.git] / reports / slice-20j / observations.lisp
1 ;; Documentary re-execution, no case registration or ASDF test system added.
2 (require :asdf)
3 (load (merge-pathnames "scripts/fresh-sbcl.lisp" (uiop:ensure-directory-pathname (uiop:getenv "TOPIC_MAPS_20J_ROOT"))))
4 (in-package :cl-user)
5 (defun hex-bytes (bytes) (format nil "~{~2,'0X~^ ~}" (coerce bytes 'list)))
6 (let* ((corpus topic-maps.ctm.tests::*cxtm-corpus*)
7 (cases (topic-maps.test-foundation:corpus-cases corpus))
8 (open (remove-if-not (lambda (case) (eq :not-run (topic-maps.test-foundation:test-case-status case))) cases))
9 (before (mapcar #'topic-maps.registered-original.tests::case-state cases))
10 (rows nil))
11 (assert (= 7 (length open)))
12 (dolist (case open)
13 (let* ((id (topic-maps.test-foundation:test-case-id case))
14 (doc (topic-maps.test-foundation:test-case-document-iri case))
15 (source (topic-maps.test-foundation:test-case-source-pathname case))
16 (bytes (topic-maps.registered-original.tests::binary source))
17 (baseline (topic-maps.test-foundation:test-case-expected-baseline case))
18 (expected (when baseline (topic-maps.registered-original.tests::binary baseline))))
19 (multiple-value-bind (map condition)
20 (topic-maps.registered-original.tests::captured-read
21 (lambda () (topic-maps.ctm:deserialize-file source :document-iri doc :source-name id)))
22 (let* ((held (when map (topic-maps.import.tests::handles map)))
23 (state (when map (topic-maps.import.tests::state map held)))
24 (actual (when map (topic-maps.cxtm:canonicalize-octets map :base-locator doc))))
25 (push (topic-maps.test-foundation::fields
26 "id" id "documentIRI" doc "category" (string (topic-maps.test-foundation:test-case-category case))
27 "expectedOutcome" (string (topic-maps.test-foundation:test-case-expected-outcome case))
28 "sourceBytes" (length bytes) "sourceHex" (hex-bytes bytes) "sourceText" (topic-maps.ctm::decode-utf8 bytes)
29 "baselinePath" (when baseline (namestring baseline)) "baselineBytes" (when expected (length expected))
30 "baselineText" (when expected (topic-maps.ctm::decode-utf8 expected))
31 "condition" (topic-maps.registered-original.tests::condition-data condition)
32 "model" (when map (topic-maps.template.tests::observe map))
33 "actualCXTM" (when actual (topic-maps.ctm::decode-utf8 actual)) "actualBytes" (when actual (length actual))
34 "byteExact" (if (and actual expected (equalp actual expected)) :true :false)
35 "canonicalizationPreservesMap" (if (and map (equal state (topic-maps.import.tests::state map held))) :true :false)
36 "referencesCurrent" (if (and map (topic-maps.reference.tests::references-current-p map)) :true :false))
37 rows)))))
38 (assert (equal before (mapcar #'topic-maps.registered-original.tests::case-state cases)))
39 (with-open-file (out (concatenate 'string (uiop:getenv "TOPIC_MAPS_20J_OUTPUT") "/investigation.json") :direction :output :if-exists :supersede)
40 (topic-maps.test-foundation::emit-json-value
41 (topic-maps.test-foundation::fields
42 "runtime" (lisp-implementation-version)
43 "harnessStatuses" (topic-maps.test-foundation::counts-object (getf (topic-maps.test-foundation:summarize-corpus corpus) :statuses))
44 "harnessCaseStatesUnchanged" :true "cases" (coerce (nreverse rows) 'vector)) out)
45 (terpri out)))