AtlatestRepositorysigil-geometry
sigil-geometry / tree / harness / src / geometry-harnessmain.sgl
1
;;; (geometry-harness main) - run the suite and the allocation check2
;;;3
;;; Prints one verdict line last:4
;;; HARNESS-VERDICT: PASS tests=N failed=0 alloc-checked=M alloc-bad=K5
;;; alloc-control=ok geometry-code=native6
;;; PASS means every test passed and the allocation counter's positive7
;;; control fired. The allocation result (alloc-bad) and the kind of8
;;; code the geometry procedures ran as (native or bytecode) are9
;;; reported for scripts/check-targets to gate per target.11
(define-library (geometry-harness main)12
;; (sigil core) is imported explicitly: on sigil 0.22.7 a native wasm13
;; app whose modules never import it dies at boot with14
;; "unbound variable '%set-spec!'" (core's init is only ordered first15
;; when core is in the reachable import set).16
(import (sigil core)17
(sigil io)18
(sigil test)19
(sigil geometry)20
(geometry-harness alloc)21
(geometry-harness suite))22
(export main)23
(begin24
;; A bytecode closure prints as #<procedure>; natively compiled code25
;; does not. This says which code the tests and the allocation check26
;; actually exercised.27
(define (code-kind proc)28
(if (string=? (format "~s" proc) "#<procedure>") "bytecode" "native"))30
(define (main . args)31
(println "harness: ~a suite modules" (length suite-modules))32
(println "harness: vec3-lerp! prints as ~a, so geometry code is ~a"33
(format "~s" vec3-lerp!) (code-kind vec3-lerp!))34
(let* ((alloc (run-alloc-check))35
(alloc-checked (car alloc))36
(alloc-bad (cadr alloc))37
(control-ok? (caddr alloc))38
(summary (run-tests-filtered (lambda (td) #t)))39
(total (test-summary-total summary))40
(failed (test-summary-failed summary)))41
(for-each (lambda (r)42
(unless (test-result-passed? r)43
(println "FAILED: ~a > ~a: ~a"44
(test-result-group r) (test-result-name r)45
(test-result-message r))))46
(test-summary-results summary))47
(let ((pass? (and control-ok? (= failed 0) (> total 0))))48
(println "HARNESS-VERDICT: ~a tests=~a failed=~a alloc-checked=~a alloc-bad=~a alloc-control=~a geometry-code=~a harness-code=~a"49
(if pass? "PASS" "FAIL") total failed alloc-checked alloc-bad50
(if control-ok? "ok" "SETUP-FAILED")51
(code-kind vec3-lerp!)52
;; control for the detector: the harness's own procedure53
(code-kind code-kind))54
(unless pass? (exit 1))55
0)))))