]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-21f/failure-controls.lisp
feat(tmdm): readers for the TMDM 7.2/7.3 relationships; tests for both default name...
[topic-maps.git] / reports / slice-21f / failure-controls.lisp
1 ;; The existing positive/negative executor guards now use valid-but-excluded
2 ;; Name Variant for Unsupported. Old reports and their historical fixtures stay
3 ;; unchanged. Target one real contract in a disposable fresh ASDF process.
4 (require :asdf)
5 (assert (string= "2.5.4" (lisp-implementation-version)))
6 (setf *compile-verbose* nil *load-verbose* nil)
7 (asdf:load-asd (merge-pathnames "../../topic-maps.asd" *load-truename*))
8 (asdf:load-system "topic-maps/xtm/tests")
9 (let* ((family (uiop:getenv "TOPIC_MAPS_21F_FAMILY")) (mode (uiop:getenv "TOPIC_MAPS_21F_FAULT"))
10 (target (cond ((string= family "positive") "xtm2/in/empty.xtm")
11 ((string= family "negative") "xtm2/invalid/id-invalid.xtm")
12 ((string= family "name") "xtm2/in/name.xtm")
13 ((string= family "scope") "xtm2/in/name-scope.xtm")
14 ((string= family "iid") "xtm2/in/itemid-name.xtm")
15 (t (error "Unknown control family ~S" family)))))
16 (if (string= mode "mismatch")
17 (let ((saved (symbol-function 'topic-maps.cxtm:canonicalize-octets))
18 (iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" target)))
19 (setf (symbol-function 'topic-maps.cxtm:canonicalize-octets)
20 (lambda (map &rest args)
21 (let ((actual (apply saved map args)))
22 (if (equal iri (getf args :base-locator))
23 (let ((changed (copy-seq actual))) (setf (aref changed 0) (logxor 1 (aref changed 0))) changed)
24 actual)))))
25 (let* ((saved (symbol-function 'topic-maps.xtm:deserialize-octets))
26 (source (cond ((string= mode "xml") "<a><b></a>")
27 ((string= mode "unsupported") (topic-maps.xtm.tests::document "<topic id='a'><name><value>N</value><variant><scope><topicRef href='#s'/></scope><resourceData>V</resourceData></variant></name></topic>"))
28 ((string= mode "tmdm") (topic-maps.xtm.tests::document "<itemIdentity href='#a'/><topic id='a'/>"))
29 ((string= mode "xtm") (topic-maps.xtm.tests::document "<topic id='2bad'/>"))
30 ((string= mode "wrong-cause") (topic-maps.xtm.tests::document "<topic/>"))
31 ((string= mode "accepted") (topic-maps.xtm.tests::document "<topic id='valid'/>"))
32 (t (error "Unknown control mode ~S" mode)))))
33 (setf (symbol-function 'topic-maps.xtm:deserialize-octets)
34 (lambda (raw &rest args)
35 (apply saved (if (equal target (getf args :source-key)) (topic-maps.xtm.tests::bytes source) raw) args)))))
36 (asdf:test-system "topic-maps/xtm"))
37 (error "Fault injection did not cause the required ASDF failure.")