(require :asdf) (assert (string= "2.5.4" (lisp-implementation-version))) (setf *compile-verbose* nil *load-verbose* nil) (asdf:load-asd (merge-pathnames "topic-maps.asd" (uiop:ensure-directory-pathname (uiop:getenv "TOPIC_MAPS_21O_ROOT")))) (asdf:load-system "topic-maps/xtm/tests") (in-package :topic-maps.xtm.tests) (when (uiop:getenv "TOPIC_MAPS_21O_BASELINE") (asdf:test-system "topic-maps/xtm") (write-report (uiop:getenv "TOPIC_MAPS_21O_BASELINE"))) (let ((rows nil)) (dolist (p (sort (append (directory (corpus-path "xtm2/in/*.xtm")) (directory (corpus-path "xtm2/invalid/*.xtm"))) #'string< :key #'namestring)) (let* ((id (concatenate 'string "xtm2/" (if (search "/invalid/" (namestring p)) "invalid/" "in/") (file-namestring p))) (iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id)) (raw (file-bytes p)) (map nil) (c (handler-case (progn (setf map (deserialize-octets raw :document-iri iri :source-key id)) nil) (error (c) c))) (actual (when map (topic-maps.cxtm:canonicalize-octets map :base-locator iri))) (baseline (corpus-path (concatenate 'string "xtm2/baseline/" (file-namestring p) ".cxtm")))) (when (and map (equal id "xtm2/in/variant-duplicate-reifier2.xtm")) (let ((*document* iri)) (assert (variant-reifier-current-p map)) (assert (= 1 (length (all-variants map)))) (let* ((v (first (all-variants map))) (n (variant-parent v)) (r (item-reifier v))) (assert (eq v (topic-reified r))) (assert (eq r (by-id map "reifier"))) (assert (equal "TOPIC!" (variant-value v))) (assert (equal "Topic" (topic-name-value n))) (assert (null (item-reifier n))) (assert (null (item-identifiers v))) (assert (scope-eq-p (variant-scope v) (list (by-id map "command"))))) (assert (equalp actual (file-bytes baseline))) (let ((before (variant-state map))) (assert (equalp actual (topic-maps.cxtm:canonicalize-octets map :base-locator iri))) (assert (equal before (variant-state map)))) (with-open-file (out (uiop:getenv "TOPIC_MAPS_21O_EXTRA") :direction :output :if-exists :supersede) (topic-maps.test-foundation::emit-json-value (topic-maps.test-foundation::fields "id" id "registered" :false "registeredStatus" "not-run" "model" (variant-reifier-model-data map) "actualCXTM" (babel:octets-to-string actual :encoding :utf-8) "byteExact" :true "condition" nil) out) (terpri out)))) (push (topic-maps.test-foundation::fields "id" id "documentIRI" iri "condition" (map-reifier-condition-data c) "status" (if map "deserialized" "rejected") "actualCXTM" (when actual (babel:octets-to-string actual :encoding :utf-8)) "byteExact" (if (and actual (probe-file baseline) (equalp actual (file-bytes baseline))) :true :false)) rows))) (assert (= 124 (length rows))) (with-open-file (out (uiop:getenv "TOPIC_MAPS_21O_DIAGNOSTICS") :direction :output :if-exists :supersede) (topic-maps.test-foundation::emit-json-value (coerce (nreverse rows) 'vector) out) (terpri out))) (assert (not (find-package :topic-maps.ctm)))