Commitc4ec67b3Recorded17 Nov 2026Repositorysigil-ui
Add the macOS qualification packet and drawing fixture
Message
Build a pinned Mac qualification packet that launches the AppKit host, conformance, WebKit, initialization, CoreText and UI drawing fixtures from fresh copies, checks each executable bit and content hash before any launch, and keeps running independent fixtures after one fails. The drawing fixture converts the expected sRGB colors into the bitmap profile before comparing raw backing-store samples.
Changed
docs/macos-qualification.md | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
docs/macos.md | 3 +++
scripts/macos/audit-native-groups.sgl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/macos/check.sgl | 34 ++++++++++++++++++++++++++++++++++
scripts/macos/prepare-qualification.sgl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/macos/setup.sgl | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/macos/test-fixture-arguments.sgl | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/macos/test-packet.sgl | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/macos/verify.sgl | 18 ++++++++++++++++++
test/macos-drawing/.gitignore | 4 ++++
test/macos-drawing/native/capture.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/macos-drawing/package.sgl | 37 +++++++++++++++++++++++++++++++++++++
test/macos-drawing/src/drawing/main.sgl | 47 +++++++++++++++++++++++++++++++++++++++++++++++
test/macos-drawing/src/drawing/native.sgl | 3 +++
test/macos/fixture-arguments.sgl | 8 ++++++++
test/macos/qualify.sgl | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16 files changed, 949 insertions(+)Diff
docs/macos-qualification.mdadded
@@ -0,0 +1,120 @@
+1
# Reproducing the combined Mac qualification+2
+3
This repository owns the font/window/UI integration fixture and its combined+4
packet. Font-specific C models/object gates remain in sigil-font. The single+5
resource monitor is scripts/macos/setup.sgl, shared by the UI check and native+6
dependency audit. Limits and candidate source directories are explicit inputs;+7
the font gates contain no machine-specific affinity, memory or disk policy.+8
+9
Use Sigil 0.24.8 and Zig 0.16.0 on Linux. Set SIGIL_MACOS_FONT_SOURCE and+10
SIGIL_MACOS_WINDOW_SOURCE to absolute accepted candidate source directories.+11
Set SIGIL_FEATURES=cross,darwin for dependency installation and Mac builds.+12
From test/macos-drawing, run `sigil deps install` then+13
`sigil build -c darwin-arm64`. The manifest selects this repository's UI and the+14
two supplied candidates by qualified local names.+15
+16
The drawing host deliberately enables `SIGIL_FONT_CORETEXT_TEST` so the private+17
fixture can use allocation/test-constructor hooks. Ordinary font/UI release+18
builds omit that test-hook flag.+19
+20
From the font source's+21
test/coretext-host, install dependencies and build both darwin-arm64 and+22
darwin-amd64. The drawing host and all its integration source are tracked here;+23
no generated project outside the repository is required.+24
+25
To use the shared Linux process/resource guard, run from this repository:+26
+27
```text+28
sigil scripts/macos/check.sgl FONT WINDOW ZIG HEADERS RESOURCE_ROOT CPUS NICE MEMORY_BYTES FREE_BYTES SCRATCH_BYTES TIMEOUT_SECONDS ACTION [EXTRA]+29
```+30
+31
The actions are objects, loader-model, caller-error (EXTRA is a matching Linux+32
runtime archive), ownership-model (also takes that archive), font-arm64,+33
font-amd64 and drawing. Linux-build,+34
linux-unicode and linux-conformance use font's tracked test/freetype-host.+35
The check delegates the first three to font's own gate and builds integration packages for+36
the rest. Every child inherits the supplied affinity, priority and address+37
limit; the shared monitor checks process-group RSS, free disk, owned build+38
directories and deadline. Nested build directories are counted only once.+39
RESOURCE_ROOT identifies additional owned build/cache scratch to count.+40
+41
The optional full dependency object audit has the same arguments; use audit as+42
ACTION and an installed registry source directory as EXTRA with+43
scripts/macos/audit-native-groups.sgl. It compiles the selected locked FFI,+44
crypto, TLS and SVG sources for both architectures. Then run:+45
+46
```text+47
sigil scripts/macos/verify.sgl FONT FONT_OBJECT_DIRECTORY NATIVE_AUDIT_DIRECTORY+48
```+49
+50
This shares font's Mach-O parser and checks font, dependency/runtime objects+51
and the real drawing image. Object proof does not replace a full application+52
link or native Mac behavior.+53
+54
Assemble the prebuilt packet using the independently accepted host packet:+55
+56
```text+57
sigil scripts/macos/prepare-qualification.sgl FONT HOST_PACKET HOST_MANIFEST_SHA256 OUTPUT+58
```+59
+60
Record the resulting manifest hash independently. Transfer OUTPUT intact to+61
an arm64 Mac and run:+62
+63
```text+64
sigil /absolute/packet/qualify.sgl /absolute/fresh/run-directory EXPECTED_MANIFEST_SHA256 --execute+65
```+66
+67
Omit --execute for a read-only plan. The script verifies the external manifest+68
pin and each fixture's owner execute bit before creating any scratch. Assembly+69
explicitly sets all six executables to mode 0755. The execute mode copies+70
sources/fonts/bundles to fresh scratch, checks every copied input+71
against the validated manifest, clears quarantine on its own copies, and+72
directly executes each copied bundle executable once, retaining its real process+73
exit status as well as its PID/hash/exit receipt. Host, conformance, WK adoption+74
and initialization receive RUN only; font and drawing receive RUN RESOURCES.+75
An exit before START reports its own error and actual process status, with+76
pre-START stdout/stderr retained beside the native receipts. No compiler, package download+77
or system font installation runs on the Mac. Process-only test registrations+78
are cleaned up. Native results remain a release gate.+79
+80
An individual fixture's behavior failure is recorded in fixture.failure, and+81
the remaining independent fixtures still run, including drawing. The aggregate+82
qualification.result lists every PASS/FAIL and the command fails if any fixture+83
failed. Manifest or copied-input integrity failures remain fatal before launch.+84
+85
The portable Unicode font suite must pass on Linux FreeType before sealing+86
each packet. It uses the pinned cmap's U+1F800 supplementary outline and a+87
small synthetic missing-outline admission case; an oversized system emoji file+88
does not qualify outline refusal. The font CI also runs these portable cases.+89
+90
For a Linux-only packet control run, use+91
`sigil scripts/macos/test-packet.sgl PACKET FRESH_ABSOLUTE_MODEL_DIRECTORY`.+92
It substitutes controlled OS tools, verifies valid/invalid plan behavior, and+93
modifies a copied scratch executable to prove refusal before launch. Its logs+94
are explicitly models; they never count as real Mac behavior. The shared+95
check's packet action accepts those two paths after ACTION for the same run+96
under the supplied resource limits.+97
The font-only failure control also requires the subsequent drawing fixture to+98
pass while the aggregate command remains a failure.+99
The non-executable-fixture control changes only a fixture's mode to 0644,+100
verifies that every content hash still matches, and requires the plan to refuse+101
it without creating its destination.+102
+103
The native drawing capture searches all content subviews for the host canvas.+104
It converts known sRGB background/white colors into the bitmap's attached ICC+105
colorSpace and compares raw getPixel components in that profile, handling+106
alpha-first/last RGB layouts explicitly. The supported cache is 8-bit RGB(A).+107
The background uses a two-level channel tolerance and must cover at least 75%+108
of all pixels. Near-white coverage uses a 14-level tolerance around the+109
profile-matched white and must reach 200 pixels. The capture logs colorSpaceName+110
separately from the attached profile, expected device values, raw samples,+111
dimensions, format and counts. colorAtX:y: is unsuitable here because its named+112
calibrated RGB decode can differ from the attached display profile. The+113
renderer's sRGB image path is unchanged.+114
+115
Run `sigil scripts/macos/test-fixture-arguments.sgl WINDOW FONT C_COMPILER FRESH_OUTPUT`+116
on Linux to test the launcher's shared argv against all six actual argument+117
admission prefixes. The control compiles the native C main guards and evaluates+118
the Sigil main admission forms, replacing only probe setup with a side-effect-free+119
stub. It never invokes native Mac or drawing behavior. Use the shared check's+120
arguments action with C_COMPILER and FRESH_OUTPUT for resource-guarded execution.docs/macos.mdmodified
@@ -1,5 +1,8 @@
1
# macOS drawing adapter 2
+3
See [combined Mac qualification](macos-qualification.md) for the reproducible+4
prebuilt font/window/UI fixture, configurable Linux gates and packet procedure.+5
6
sigil-ui 0.2.6 draws into sigil-window 0.2.0's SDK-free AppKit host. 7
`(sigil ui window)` selects the AppKit adapter on Darwin. Existing 8
`appkit-*` names in `(sigil ui appkit)` remain available: open/close,scripts/macos/audit-native-groups.sgladded
@@ -0,0 +1,50 @@
+1
(import (sigil shell prelude))+2
(load (path (script-dir) "setup.sgl"))+3
(import (sigil package) (sigil build))+4
(define registry (realpath (arg 13)))+5
(define inventory '())+6
(define (package-root name version)+7
(define matches (glob (path registry (str "sigil%2Fsigil-" name "-" version "-*" "/package.sgl"))))+8
(unless (= 1 (length matches)) (error "Expected exact locked source" name version matches))+9
(dirname (car matches)))+10
(define crypto (package-root "crypto" "0.19.2"))+11
(define crypto-includes+12
(map (lambda (file) (path crypto file))+13
'("vendor/mbedtls/include" "vendor/mbedtls"+14
"vendor/monocypher/src" "vendor/monocypher/src/optional")))+15
(each group '(("ffi" "0.16.6") ("crypto" "0.19.2") ("tls" "0.16.11") ("svg" "0.1.0"))+16
(define name (car group))+17
(define source-root (package-root name (cadr group)))+18
(define package (load-package (path source-root "package.sgl")))+19
(unless (= 1 (length (package-libraries package))) (error "Unexpected native library count" name))+20
(define library (car (package-libraries package)))+21
(define sources+22
(apply append (map (lambda (pattern) (glob (path source-root pattern)))+23
(library-c-sources library))))+24
(unless (pair? sources) (error "No selected native sources" name))+25
(define includes+26
(append (list headers (path (dirname headers) "src"))+27
(map (lambda (file) (path source-root file)) (library-c-include-dirs library))+28
(cond+29
((equal? name "ffi")+30
(map (lambda (file) (path source-root file))+31
'("vendor/dyncall/dyncall" "vendor/dyncall/dyncallback")))+32
((equal? name "tls") crypto-includes)+33
(else '()))))+34
(set! inventory (cons (list name (cadr group) source-root sources includes+35
(library-c-flags library)) inventory))+36
(each arch '("aarch64" "x86_64")+37
(define output (path build "native-audit" arch name))+38
(ensure-directory output)+39
(each source sources+40
(define relative (path-relative source-root source))+41
(define object (str (string-replace relative "/" "_") ".o"))+42
(compile! (str "audit-" arch "-" name "-" object)+43
(append (list "-target" (str arch "-macos.15.0-none") "-mmacosx-version-min=15.0"+44
"-std=c11" "-O1" "-D_DARWIN_C_SOURCE" "-D_GNU_SOURCE"+45
"-Wall" "-Wextra" "-Wno-unused-parameter")+46
(apply append (map (lambda (directory) (list "-I" directory)) includes))+47
(library-c-flags library)+48
(list "-c" source "-o" (path output object)))))))+49
(write-text (path build "native-audit/INPUTS.sgl") (format "~s\n" (reverse inventory)))+50
(println "PASS: all selected FFI, crypto, TLS and SVG units on both Mac architectures")scripts/macos/check.sgladded
@@ -0,0 +1,34 @@
+1
;;; FONT WINDOW ZIG HEADERS RESOURCE_ROOT CPUS NICE MEMORY FREE SCRATCH SECONDS ACTION [EXTRA]+2
(import (sigil shell prelude))+3
(load (path (script-dir) "setup.sgl"))+4
(define cli (or (getenv "SIGIL") "sigil"))+5
(define action (arg 12))+6
(define (font-gate! name)+7
(guarded! name cli+8
(append (list (path font "scripts/check-sdk-free.sgl") zig headers name (str maximum-seconds))+9
(if (member name '("caller-error" "ownership-model")) (list (realpath (arg 13))) '())) "/tmp"))+10
(cond+11
((member action '("objects" "loader-model" "caller-error" "ownership-model")) (font-gate! action))+12
((equal? action "font-arm64")+13
(guarded! action cli '("build" "-c" "darwin-arm64") (path font "test/coretext-host")))+14
((equal? action "font-amd64")+15
(guarded! action cli '("build" "-c" "darwin-amd64") (path font "test/coretext-host")))+16
((equal? action "drawing")+17
(setenv! "SIGIL_MACOS_FONT_SOURCE" font)+18
(setenv! "SIGIL_MACOS_WINDOW_SOURCE" window)+19
(guarded! action cli '("build" "-c" "darwin-arm64") (path root "test/macos-drawing")))+20
((equal? action "linux-build")+21
(guarded! action cli '("build" "-c" "dev") (path font "test/freetype-host")))+22
((equal? action "linux-unicode")+23
(guarded! action (path font "test/freetype-host/build/dev/bin/font-linux-tests")+24
(list (path font "test/test-coretext-unicode.sgl")) font))+25
((equal? action "linux-conformance")+26
(guarded! action (path font "test/freetype-host/build/dev/bin/font-linux-tests")+27
(list (path font "test/test-conformance.sgl")) font))+28
((equal? action "packet")+29
(guarded! action cli (list (path root "scripts/macos/test-packet.sgl")+30
(realpath (arg 13)) (arg 14)) "/tmp"))+31
((equal? action "arguments")+32
(guarded! action cli (list (path root "scripts/macos/test-fixture-arguments.sgl")+33
window font (realpath (arg 13)) (arg 14)) "/tmp"))+34
(else (error "Unknown qualification action" action)))scripts/macos/prepare-qualification.sgladded
@@ -0,0 +1,51 @@
+1
;;; FONT HOST_PACKET HOST_MANIFEST_SHA256 OUTPUT — assemble prebuilt images only.+2
(import (sigil shell prelude))+3
(requires (tools cp chmod sha256sum))+4
(define root (realpath (path (script-dir) "../..")))+5
(define font (realpath (arg 1)))+6
(define host (realpath (arg 2)))+7
(define expected-host (arg 3))+8
(define destination (arg 4))+9
(unless (and (starts-with? destination "/") (not (file-exists? destination)))+10
(error "Expected a fresh absolute packet directory"))+11
(unless (equal? expected-host (car (regex-split "\\s+" (out sha256sum ,(path host "SHA256SUMS")))))+12
(error "Host manifest differs from its external pin"))+13
($ sha256sum --quiet -c SHA256SUMS cwd: ,host)+14
(ensure-directory destination)+15
(define (copy! source name)+16
(define output (path destination name))+17
(ensure-directory (dirname output))+18
($ cp ,source ,output))+19
(each name '("host-aarch64" "appkit-conformance" "webkit-aarch64" "initialization-aarch64" "Info.plist")+20
(copy! (path host name) name))+21
(copy! (path root "test/macos/qualify.sgl") "qualify.sgl")+22
(copy! (path root "test/macos/fixture-arguments.sgl") "fixture-arguments.sgl")+23
(copy! (path font "test/coretext-host/build/darwin-arm64/bin/sigil-font-coretext-tests") "font-aarch64")+24
(copy! (path root "test/macos-drawing/build/darwin-arm64/bin/sigil-font-ui-drawing-tests") "ui-drawing-aarch64")+25
(each name '("host-aarch64" "appkit-conformance" "webkit-aarch64" "initialization-aarch64"+26
"font-aarch64" "ui-drawing-aarch64")+27
($ chmod "755" ,(path destination name)))+28
(each name '("JetBrainsMono-Regular.ttf" "JetBrainsMono-Bold.ttf" "NotoSansSymbols2-Regular.ttf"+29
"OFL.txt" "Noto-Symbols-OFL.txt" "README.md" "helpers.sgl")+30
(copy! (path font "test/fixtures" name) (path "font/fixtures" name)))+31
(each name '("test-conformance.sgl" "test-coretext-lifetime.sgl" "test-coretext-unicode.sgl")+32
(copy! (path font "test" name) (path "font/test" name)))+33
(each entry '(("native/coretext.c" "coretext.c") ("native/coretext-runtime.c" "coretext-runtime.c")+34
("native/coretext-runtime.h" "coretext-runtime.h")+35
("test/coretext-host/native/fixture.c" "fixture.c")+36
("test/coretext-host/src/sigil/font/tests/coretext.sgl" "coretext-main.sgl")+37
("test/coretext-host/native/probe-support.h" "probe-support.h")+38
("test/coretext-host/native/collection-support.h" "collection-support.h")+39
("test/coretext-host/src/sigil/font/tests/fixtures.sgl" "fixture-module.sgl")+40
("test/coretext-host/package.sgl" "coretext-package.sgl") ("package.sgl" "font-package.sgl"))+41
(copy! (path font (car entry)) (path "font/source" (cadr entry))))+42
(each entry '(("src/drawing/main.sgl" "drawing-main.sgl") ("src/drawing/native.sgl" "drawing-native.sgl")+43
("native/capture.c" "capture.c") ("package.sgl" "drawing-package.sgl"))+44
(copy! (path root "test/macos-drawing" (car entry)) (path "font/source" (cadr entry))))+45
(define names (map (lambda (file) (path-relative destination file))+46
(filter file? (directory-walk-list destination))))+47
(unless (= 33 (length names)) (error "Incomplete qualification packet" (length names)))+48
(write-text (path destination "SHA256SUMS") (str (out sha256sum ,@names cwd: ,destination) "\n"))+49
($ sha256sum --quiet -c SHA256SUMS cwd: ,destination)+50
(println "PASS: 33 exact inputs; independently record this manifest pin")+51
($ sha256sum ,(path destination "SHA256SUMS"))scripts/macos/setup.sgladded
@@ -0,0 +1,110 @@
+1
#!/usr/bin/env sigil+2
;;; SDK-free compile and ABI checks; run from Linux, never opens a display.+3
(import (sigil shell prelude) (only (sigil list) any))+4
(requires (tools taskset nice prlimit df du ps))+5
(define root (realpath (path (script-dir) "../..")))+6
(define font (realpath (arg 1)))+7
(define window (realpath (arg 2)))+8
(define zig (realpath (arg 3)))+9
(define headers (realpath (arg 4)))+10
(define resource-root (realpath (arg 5)))+11
(define cpu-list (arg 6))+12
(define desired-nice (string->number (arg 7)))+13
(define maximum-memory (string->number (arg 8)))+14
(define minimum-free (string->number (arg 9)))+15
(define maximum-scratch (string->number (arg 10)))+16
(define maximum-seconds (string->number (arg 11)))+17
(unless (and desired-nice maximum-memory minimum-free maximum-scratch maximum-seconds+18
(<= 0 desired-nice 19) (> maximum-memory 0) (> minimum-free 0)+19
(> maximum-scratch 0) (> maximum-seconds 0))+20
(error "Expected explicit positive resource limits"))+21
(define build (path root "build/macos-qualification"))+22
(unless (and (equal? (out ,zig version) "0.16.0")+23
(file? (path headers "sigil/sigil.h"))+24
(file? (path font "native/coretext.c")))+25
(error "Expected Zig 0.16.0, matching Sigil headers, and the font candidate"))+26
(each name '("tmp" "cache" "global-cache" "logs")+27
(ensure-directory (path build name)))+28
(setenv! "TMPDIR" (path build "tmp"))+29
(setenv! "ZIG_LOCAL_CACHE_DIR" (path build "cache"))+30
(setenv! "ZIG_GLOBAL_CACHE_DIR" (path build "global-cache"))+31
(define priority (string->number (trim (out ps -p ,(process-id) -o "ni="))))+32
(unless priority (error "Cannot inspect caller priority"))+33
(define (scratch-directories)+34
(define candidates '())+35
(each directory (list (path resource-root "build") (path root "build") (path font "build")+36
(path font "test/coretext-host/build") (path root "test/macos-drawing/build")+37
(path font "test/freetype-host/build")+38
(path window "build") (path window "test/appkit/conformance/build"))+39
(when (directory? directory)+40
(define canonical (realpath directory))+41
(unless (member canonical candidates) (set! candidates (cons canonical candidates)))))+42
(filter (lambda (directory)+43
(not (any (lambda (other)+44
(and (not (equal? directory other))+45
(starts-with? directory (str other "/")))) candidates)))+46
candidates))+47
(define (room! group)+48
(let ((disk (regex-split "\\s+" (trim (cadr (lines df -Pk ,root)))))+49
(scratch 0)+50
(rss 0))+51
(each directory (scratch-directories)+52
(define usage ($? du -sk ,directory))+53
;; Zig removes temporary objects concurrently. Accept only ENOENT in+54
;; this owned directory, with a valid summary; other failures stop work.+55
(unless (or (ok? usage)+56
(and (= (exit-status usage) 1)+57
(every (lambda (line)+58
(or (string=? line "")+59
(and (contains? line (str "cannot access '" directory "/"))+60
(ends-with? line "': No such file or directory"))))+61
(split (stderr-of usage) "\n"))))+62
(error "Cannot measure owned scratch" (format-outcome usage)))+63
(define fields (regex-split "\\s+" (trim (stdout-of usage))))+64
(unless (and (pair? fields) (string->number (car fields)))+65
(error "Missing scratch summary" directory))+66
(set! scratch (+ scratch (string->number (car fields)))))+67
(when (< (string->number (list-ref disk 3)) (quotient minimum-free 1024))+68
(error "Free disk crossed the supplied floor"))+69
(when (>= (* scratch 1024) maximum-scratch)+70
(error "Scratch crossed the supplied limit"))+71
(when group+72
(each row (lines ps -eo "pgid=,rss=")+73
(let ((fields (regex-split "\\s+" (trim row))))+74
(when (and (= (length fields) 2)+75
(= (string->number (car fields)) group))+76
(set! rss (+ rss (string->number (cadr fields))))))))+77
(when (>= rss (quotient maximum-memory 1024))+78
(error "Owned process group crossed the supplied RSS limit"))))+79
(define (guarded! name executable arguments (opts: (directory root)))+80
(room! #f)+81
(let ((child #f) (started (current-milliseconds))+82
(log-file (path build "logs" (str name ".log"))))+83
(dynamic-wind+84
(lambda () #f)+85
(lambda ()+86
(set! child+87
(apply process-spawn (tool-path 'taskset)+88
(append+89
(list "-c" cpu-list (tool-path 'nice) "-n" (str (max 0 (- desired-nice priority)))+90
(tool-path 'prlimit) (str "--as=" maximum-memory) "--" executable)+91
arguments+92
(list new-process-group: #t die-with-parent: #t+93
cwd: directory in: "/dev/null" out: log-file err: #t))))+94
(let poll ()+95
(when (process-alive? child)+96
(room! (process-pgid child))+97
(when (> (- (current-milliseconds) started) (* maximum-seconds 1000))+98
(error "Process exceeded the supplied deadline" name))+99
(sleep 0.5)+100
(poll)))+101
(unless (= 0 (process-wait child))+102
(error "Compilation failed" name (read-text log-file)))+103
(room! #f)+104
(println "PASS: ~a" name))+105
(lambda ()+106
(when child+107
(when (process-alive? child) (process-signal! child 'kill))+108
(process-wait child))))))+109
(define (compile! name arguments)+110
(guarded! name zig (cons "cc" arguments)))scripts/macos/test-fixture-arguments.sgladded
@@ -0,0 +1,88 @@
+1
;;; WINDOW FONT C_COMPILER FRESH_OUTPUT — Linux argument-parser controls only.+2
(import (sigil shell prelude) (sigil list))+3
(requires (tools sigil))+4
(define root (realpath (path (script-dir) "../..")))+5
(define window (realpath (arg 1)))+6
(define font (realpath (arg 2)))+7
(define compiler (realpath (arg 3)))+8
(define output (arg 4))+9
(define cli (or (getenv "SIGIL") (tool-path 'sigil)))+10
(unless (and (starts-with? output "/") (not (file-exists? output)))+11
(error "Supply a fresh absolute parser-control output directory"))+12
(load (path root "test/macos/fixture-arguments.sgl"))+13
(ensure-directory output)+14
(define run (path output "run with spaces"))+15
(define resources (path output "owned resources"))+16
(define checks 0)+17
(define (check name executable arguments expected)+18
(define result ($? ,executable ,@arguments timeout: 15))+19
(write-text (path output (str name ".log"))+20
(str "Linux argument parser only; native/font/UI operations are not executed.\n"+21
(stdout-of result) (stderr-of result) "\n" (format-outcome result) "\n"))+22
(unless (equal? expected (exit-status result))+23
(error "Argument parser control failed" name (format-outcome result)))+24
(set! checks (+ checks 1))+25
(println "PASS: ~a" name))+26
+27
;;; Compile the real first C main guard, substituting only probe_begin. Refuse+28
;;; unfamiliar syntax so a changed entrypoint cannot silently escape coverage.+29
(each entry '(("host-aarch64" "test/appkit/host.c")+30
("webkit-aarch64" "test/appkit/webkit.c")+31
("initialization-aarch64" "test/appkit/initialization.c"))+32
(define name (car entry))+33
(define source (read-text (path window (cadr entry))))+34
(define guard-match+35
(regex-search "int main\\(int argc, char \\*\\*argv\\) \\{\\s*(if \\(argc != 2 \\|\\| !probe_begin\\(argv\\[1\\]\\)\\) return 2;)" source))+36
(unless guard-match (error "Unrecognized native argument parser" name))+37
(define c-file (path output (str name ".c")))+38
(define executable (path output name))+39
(write-text c-file+40
(str "#include <stdbool.h>\n#include <string.h>\n"+41
"static bool probe_begin(const char *directory) { return strcmp(directory, "+42
(format "~s" run) ") == 0; }\nint main(int argc, char **argv) {\n"+43
(match-group guard-match 1) "\nreturn 0;\n}\n"))+44
($ ,compiler -std=c11 -Wall -Wextra -Werror ,c-file -o ,executable timeout: 30)+45
(check (str name "-exact-argv") executable (fixture-arguments name run resources) 0)+46
(check (str name "-missing-run") executable '() 2)+47
(check (str name "-old-two-arguments") executable (list run resources) 2))+48
+49
;;; Read actual Sigil main forms. Execute only its argument admission prefix,+50
;;; with a lexical command-line binding and a side-effect-free begin probe.+51
(each entry+52
(list (list "appkit-conformance" (path window "test/appkit/conformance/src/conformance/main.sgl"))+53
(list "font-aarch64" (path font "test/coretext-host/src/sigil/font/tests/coretext.sgl"))+54
(list "ui-drawing-aarch64" (path root "test/macos-drawing/src/drawing/main.sgl")))+55
(define name (car entry))+56
(define library (call-with-input-file (cadr entry) read))+57
(define body (find (lambda (form) (and (pair? form) (eq? (car form) 'begin))) (cddr library)))+58
(unless body (error "Missing fixture library body" name))+59
(define main-form+60
(find (lambda (form) (and (pair? form) (eq? (car form) 'define)+61
(equal? (cadr form) '(main)))) (cdr body)))+62
(unless main-form (error "Missing fixture main" name))+63
(define admission+64
(if (equal? name "appkit-conformance")+65
(list (caddr main-form))+66
(list (caddr main-form) (cadddr main-form))))+67
(unless (if (equal? name "appkit-conformance")+68
(and (eq? (caar admission) 'let) (= (length (car admission)) 3)+69
(eq? (car (caddr (car admission))) 'unless))+70
(and (equal? (car admission) '(define args (cdr (command-line))))+71
(eq? (car (cadr admission)) 'unless)))+72
(error "Unrecognized Sigil argument admission prefix" name))+73
(define parser (path output (str name ".sgl")))+74
(write-text parser+75
(str "(import (sigil shell prelude))\n(define argument-probe-began #f)\n"+76
"(define (parser-begin directory)\n (set! argument-probe-began #t)\n (equal? directory "+77
(format "~s" run) "))\n"+78
"(let ((command-line (lambda () (cons \"fixture\" (script-args)))))\n"+79
" (let ((probe-begin! parser-begin) (%fixture-begin! parser-begin))\n"+80
(string-join (map (lambda (form) (format "~s" form)) admission) "\n")+81
"\n (unless argument-probe-began (error \"Parser did not call begin\"))))\n"))+82
(define arguments (fixture-arguments name run resources))+83
(check (str name "-exact-argv") cli (cons parser arguments) 0)+84
(check (str name "-missing-run") cli (list parser) 2)+85
(unless (equal? name "appkit-conformance")+86
(check (str name "-missing-resources") cli (list parser run) 2)+87
(check (str name "-extra-argument") cli (append (list parser) arguments '("extra")) 2)))+88
(println "PASS: ~a actual-parser controls; all six fixtures use the launcher's shared argv builder" checks)scripts/macos/test-packet.sgladded
@@ -0,0 +1,118 @@
+1
;;; Linux-only controlled tool model. Never a real Mac behavior receipt.+2
(import (sigil shell prelude))+3
(requires (tools sigil chmod cp sha256sum))+4
(define packet (realpath (arg 1)))+5
(define work (arg 2))+6
(define cli (or (getenv "SIGIL") (tool-path 'sigil)))+7
(unless (and (starts-with? work "/") (not (file-exists? work)))+8
(error "Expected a fresh absolute model directory"))+9
(define bin (path work "bin"))+10
(define logs (path work "logs"))+11
(ensure-directory bin)+12
(ensure-directory logs)+13
(define (shim name body)+14
(define file (path bin name))+15
(write-text file (str "#!" cli "\n(import (sigil shell prelude))\n" body "\n"))+16
($ chmod 700 ,file))+17
(shim "uname" "(println \"~a\" (if (equal? (arg 1) \"-s\") \"Darwin\" \"arm64\"))")+18
(shim "sw_vers" "(println \"15.6.1\")")+19
(shim "shasum" "($ sha256sum ,@(cddr (script-args)))")+20
(shim "open" "(error \"Linux model must never launch an application\")")+21
(shim "xattr" "(error \"Read-only plan must never modify attributes\")")+22
(define environment (dict "PATH" (str bin ":" (getenv "PATH"))))+23
(define pin (car (regex-split "\\s+" (out sha256sum ,(path packet "SHA256SUMS")))))+24
(define destination (path work "run"))+25
(define (check name directory expected success? message (opts: (execute? #f)))+26
(define result+27
($? ,cli ,(path directory "qualify.sgl") ,destination ,expected+28
,(if execute? "--execute" "--plan") env: ,environment err: 'merge timeout: 90))+29
(write-text (path logs (str name ".log"))+30
(str "Linux model only: controlled uname/sw_vers; no Mac accessed.\n"+31
(stdout-of result) "\n" (format-outcome result) "\n"))+32
(unless (and (eq? success? (ok? result)) (contains? (stdout-of result) message)+33
(eq? execute? (file-exists? destination)))+34
(error "Packet model failed" name (stdout-of result)))+35
(println "PASS: Linux packet model ~a" name))+36
(check "valid" packet pin #t "33 exact hashes")+37
(check "external-pin" packet (make-string 64 #\0) #f "independently supplied SHA-256")+38
(define altered (path work "altered"))+39
($ cp -R ,packet ,altered)+40
($ chmod "644" ,(path altered "ui-drawing-aarch64"))+41
($ sha256sum --quiet -c SHA256SUMS cwd: ,altered)+42
(check "non-executable-fixture" altered pin #f "Fixture is not executable")+43
($ chmod "755" ,(path altered "ui-drawing-aarch64"))+44
(write-text (path altered "font/fixtures/JetBrainsMono-Regular.ttf") "tampered")+45
(check "payload" altered pin #f "input hash mismatch")+46
($ cp ,(path packet "font/fixtures/JetBrainsMono-Regular.ttf")+47
,(path altered "font/fixtures/JetBrainsMono-Regular.ttf"))+48
(define rows (split (read-text (path altered "SHA256SUMS") trim: #t) "\n"))+49
(write-text (path altered "SHA256SUMS")+50
(str (string-join (cons (car rows) (cons (car rows) (cddr rows))) "\n") "\n"))+51
(define changed-pin (car (regex-split "\\s+" (out sha256sum ,(path altered "SHA256SUMS")))))+52
(check "duplicate-row" altered changed-pin #f "duplicate")+53
;; Tamper only with the new scratch executable after the real copy. The+54
;; pinned manifest must stop this before even the controlled open is called.+55
(shim "cp"+56
(format "($ ~s ,@(script-args))\n(define target (car (reverse (script-args))))\n(when (ends-with? target \"/runtime-probe\") (write-text target \"changed scratch executable\"))"+57
(tool-path 'cp)))+58
(shim "xattr"+59
(format "(unless (starts-with? (car (reverse (script-args))) ~s) (error \"Attribute target escaped owned model scratch\"))"+60
(str destination "/")))+61
(check "copied-executable" packet pin #f "Copied executable differs from the pinned manifest" #t)+62
+63
;; Replace the six Mach-O images only in a separate, explicitly modeled packet.+64
;; These controlled executables test direct-launch status/evidence handling.+65
(define modeled (path work "modeled-packet"))+66
($ cp -R ,packet ,modeled)+67
(each name '("host-aarch64" "appkit-conformance" "webkit-aarch64" "initialization-aarch64"+68
"font-aarch64" "ui-drawing-aarch64")+69
(define executable (path modeled name))+70
(define count (if (member name '("font-aarch64" "ui-drawing-aarch64")) 2 1))+71
(write-text executable+72
(str "#!" cli "\n(import (sigil shell prelude))\n"+73
"(define fixture-name " (format "~s" name) ")\n"+74
"(unless (= " (str count) " (length (script-args))) (exit 2))\n"+75
"(define mode (getenv \"SIGIL_PACKET_MODEL_MODE\"))\n"+76
"(when (equal? mode \"pre-start\") (display \"argument admission failed\\n\") (exit 2))\n"+77
"(define run (arg 1))\n(define pid (process-id))\n"+78
"(write-text (path run \"runtime.log\") (format \"START pid=~a\\n\" pid))\n"+79
"(unless (equal? mode \"missing-result\")\n"+80
" (define hash (car (regex-split \"\\\\s+\" (out sha256sum ,(script-file)))))\n"+81
" (write-text (path run \"runtime.result\")\n"+82
" (format \"status=~a pid=~a sha256=~a\\n\"\n"+83
" (if (or (equal? mode \"status-mismatch\")\n"+84
" (and (equal? mode \"font-only-failure\") (equal? fixture-name \"font-aarch64\"))) 1 0)\n"+85
" (if (equal? mode \"pid-mismatch\") (+ pid 1) pid)\n"+86
" (if (equal? mode \"hash-mismatch\") (make-string 64 #\\0) hash))))\n"+87
"(when (equal? mode \"process-status\") (exit 2))\n"+88
"(when (and (equal? mode \"font-only-failure\") (equal? fixture-name \"font-aarch64\")) (exit 1))\n"))+89
($ chmod 700 ,executable))+90
(define modeled-names+91
(map (lambda (row) (cadr (regex-split "\\s+" row)))+92
(split (read-text (path modeled "SHA256SUMS") trim: #t) "\n")))+93
(write-text (path modeled "SHA256SUMS")+94
(str (out sha256sum ,@modeled-names cwd: ,modeled) "\n"))+95
(define modeled-pin+96
(car (regex-split "\\s+" (out sha256sum ,(path modeled "SHA256SUMS")))))+97
(shim "cp" (format "($ ~s ,@(script-args))" (tool-path 'cp)))+98
(shim "xattr"+99
(format "(unless (starts-with? (car (reverse (script-args))) ~s) (error \"Attribute target escaped model scratch\"))"+100
(str work "/")))+101
(each control '(("direct-success" "pass" #t "PASS: AppKit, CoreText and native UI drawing")+102
("pre-start-status-2" "pre-start" #f "no START line (exit status 2;")+103
("pid-mismatch" "pid-mismatch" #f "exit/PID/hash evidence did not match")+104
("hash-mismatch" "hash-mismatch" #f "exit/PID/hash evidence did not match")+105
("status-mismatch" "status-mismatch" #f "exit/PID/hash evidence did not match")+106
("process-status" "process-status" #f "exit/PID/hash evidence did not match")+107
("missing-result" "missing-result" #f "exit/PID/hash evidence did not match")+108
("font-failure-still-draws" "font-only-failure" #f "all fixtures attempted"))+109
(set! destination (path work (car control)))+110
(set! environment (dict-set environment "SIGIL_PACKET_MODEL_MODE" (cadr control)))+111
(check (car control) modeled modeled-pin (caddr control) (cadddr control) #t)+112
(unless (file? (path destination "ui-drawing-aarch64/launch.result"))+113
(error "Failed fixture prevented the remaining drawing launch" (car control)))+114
(when (equal? (car control) "font-failure-still-draws")+115
(unless (contains? (read-text (path destination "qualification.result"))+116
"font-aarch64 FAIL\nui-drawing-aarch64 PASS")+117
(error "Font failure did not retain an independent drawing PASS"))))+118
(println "PASS: 14 Linux packet controls; controlled executables never prove Mac behavior")scripts/macos/verify.sgladded
@@ -0,0 +1,18 @@
+1
;;; FONT FONT_OBJECT_DIRECTORY NATIVE_AUDIT_DIRECTORY — no Mac execution.+2
(import (sigil shell prelude))+3
(define root (realpath (path (script-dir) "../..")))+4
(define font (realpath (arg 1)))+5
(define audit (realpath (arg 3)))+6
(define cli (or (getenv "SIGIL") "sigil"))+7
($ ,cli ,(path font "scripts/verify-sdk-free.sgl") ,(arg 2) "--images")+8
(load (path font "scripts/macho.sgl"))+9
(each arch '("aarch64" "x86_64")+10
(define cpu (if (equal? arch "aarch64") #x100000c #x1000007))+11
(each file (glob (path audit arch "**/*.o")) (verify file cpu '() #f #t))+12
(define config (if (equal? arch "aarch64") "darwin-arm64" "darwin-amd64"))+13
(define native (path font "test/coretext-host/build" config "native"))+14
(define runtime (glob (path native (str "sigil-lib-objs-" arch "-macos.15.0-none") "*.o")))+15
(unless (>= (length runtime) 80) (error "Incomplete runtime object receipt" config))+16
(each file runtime (verify file cpu '() #f #t))+17
(verify (path native "allocator-stock.o") cpu '()))+18
(verify (path root "test/macos-drawing/build/darwin-arm64/bin/sigil-font-ui-drawing-tests") #x100000c '() #t)test/macos-drawing/.gitignoreadded
@@ -0,0 +1,4 @@
+1
/build/+2
/.sigil/+3
/sigil.lock+4
/*.otest/macos-drawing/native/capture.cadded
@@ -0,0 +1,121 @@
+1
#include <sigil/sigil.h>+2
#include "appkit-runtime.h"+3
#include <math.h>+4
#include <stdio.h>+5
+6
extern void sigil__init_coretext_test_fixture(SigilVM *);+7
static bool expected_components(SWId space, double red, double green, double blue, double values[4])+8
{+9
SWId color = ((SWId (*)(SWId, SWSel, double, double, double, double))sw_appkit.message)(+10
sw_class("NSColor"), sw_sel("colorWithSRGBRed:green:blue:alpha:"), red, green, blue, 1.0);+11
SWId converted = ((SWId (*)(SWId, SWSel, SWId))sw_appkit.message)(+12
color, sw_sel("colorUsingColorSpace:"), space);+13
if (!converted || sw_uint(converted, "numberOfComponents") != 4) return false;+14
((void (*)(SWId, SWSel, double *))sw_appkit.message)(converted, sw_sel("getComponents:"), values);+15
for (unsigned index = 0; index < 4; ++index)+16
if (!isfinite(values[index])) return false;+17
return true;+18
}+19
static Value capture(SigilVM *vm, int argc, Value *args)+20
{+21
(void)argc; (void)args;+22
if (!sw_appkit_main_thread()) return SIGIL_FALSE;+23
void *pool = sw_appkit.pool_push();+24
SWId application = sw_id(sw_class("NSApplication"), "sharedApplication");+25
SWId windows = sw_id(application, "windows");+26
SWId view = NULL;+27
unsigned canvases = 0;+28
for (unsigned long index = 0; index < sw_uint(windows, "count"); ++index) {+29
SWId window = ((SWId (*)(SWId, SWSel, unsigned long))sw_appkit.message)(+30
windows, sw_sel("objectAtIndex:"), index);+31
SWId subviews = sw_id(sw_id(window, "contentView"), "subviews");+32
for (unsigned long child = 0; child < sw_uint(subviews, "count"); ++child) {+33
SWId candidate = ((SWId (*)(SWId, SWSel, unsigned long))sw_appkit.message)(+34
subviews, sw_sel("objectAtIndex:"), child);+35
if (((SWObjCBool (*)(SWId, SWSel, SWClass))sw_appkit.message)(+36
candidate, sw_sel("isKindOfClass:"), sw_class("SigilWindowCanvas"))) {+37
view = candidate;+38
++canvases;+39
}+40
}+41
}+42
if (canvases != 1) {+43
printf("CAPTURE invalid: expected one host canvas, found %u\n", canvases);+44
sw_appkit.pool_pop(pool);+45
return SIGIL_FALSE;+46
}+47
SWRect bounds = sw_bounds(view, "bounds");+48
SWId bitmap = ((SWId (*)(SWId, SWSel, SWRect))sw_appkit.message)(+49
view, sw_sel("bitmapImageRepForCachingDisplayInRect:"), bounds);+50
SWId profile = sw_id(bitmap, "colorSpace");+51
unsigned long bits = sw_uint(bitmap, "bitsPerSample");+52
unsigned long samples = sw_uint(bitmap, "samplesPerPixel");+53
unsigned long width = sw_uint(bitmap, "pixelsWide"), height = sw_uint(bitmap, "pixelsHigh");+54
unsigned long format = sw_uint(bitmap, "bitmapFormat");+55
bool alpha = sw_bool(bitmap, "hasAlpha");+56
const char *space = (const char *)sw_id(sw_id(profile, "localizedName"), "UTF8String");+57
const char *named_space = (const char *)sw_id(sw_id(bitmap, "colorSpaceName"), "UTF8String");+58
printf("CAPTURE bounds=%.3fx%.3f pixels=%lux%lu bits=%lu samples=%lu format=0x%lx profile=%s colorSpaceName=%s\n",+59
bounds.size.width, bounds.size.height, width, height, bits, samples,+60
format, space ? space : "unknown", named_space ? named_space : "unknown");+61
double expected_bg[4] = {0}, expected_white[4] = {0};+62
bool valid = bitmap && profile && bits == 8 && !(format & 4) &&+63
samples == (alpha ? 4UL : 3UL) && sw_uint(profile, "numberOfColorComponents") == 3 &&+64
width && height && width <= 2048 && height <= 2048 &&+65
expected_components(profile, 18.0 / 255, 52.0 / 255, 86.0 / 255, expected_bg) &&+66
expected_components(profile, 1, 1, 1, expected_white);+67
printf("CAPTURE source-sRGB-bg=18,52,86 expected-device-bg=%.3f,%.3f,%.3f expected-device-white=%.3f,%.3f,%.3f\n",+68
expected_bg[0] * 255, expected_bg[1] * 255, expected_bg[2] * 255,+69
expected_white[0] * 255, expected_white[1] * 255, expected_white[2] * 255);+70
unsigned long white = 0, background = 0;+71
unsigned long rgb_start = alpha && (format & 1) ? 1 : 0;+72
unsigned long alpha_index = format & 1 ? 0 : 3;+73
int brightest[4] = {0};+74
if (valid) {+75
((void (*)(SWId, SWSel, SWRect, SWId))sw_appkit.message)(+76
view, sw_sel("cacheDisplayInRect:toBitmapImageRep:"), bounds, bitmap);+77
for (unsigned long y = 0; valid && y < height; ++y) {+78
for (unsigned long x = 0; valid && x < width; ++x) {+79
unsigned long raw[4] = {0};+80
((void (*)(SWId, SWSel, unsigned long *, long, long))sw_appkit.message)(+81
bitmap, sw_sel("getPixel:atX:y:"), raw, (long)x, (long)y);+82
unsigned long opacity = alpha ? raw[alpha_index] : 255;+83
bool is_white = opacity > 240, is_background = opacity > 240;+84
for (unsigned index = 0; index < 3; ++index) {+85
double sample = (double)raw[rgb_start + index];+86
if (fabs(sample - expected_bg[index] * 255) > 2) is_background = false;+87
if (fabs(sample - expected_white[index] * 255) > 14) is_white = false;+88
}+89
int light = (int)raw[rgb_start];+90
if ((int)raw[rgb_start + 1] < light) light = (int)raw[rgb_start + 1];+91
if ((int)raw[rgb_start + 2] < light) light = (int)raw[rgb_start + 2];+92
if (light > brightest[0]) {+93
brightest[0] = light;+94
for (unsigned index = 0; index < 3; ++index) brightest[index + 1] = (int)raw[rgb_start + index];+95
}+96
if (is_white) ++white;+97
if (is_background) ++background;+98
if ((!x && !y) || (x == width / 2 && y == height / 2))+99
printf("CAPTURE sample=%lu,%lu raw=%lu,%lu,%lu,%lu profile-RGB=%lu,%lu,%lu alpha=%lu\n",+100
x, y, raw[0], raw[1], raw[2], raw[3],+101
raw[rgb_start], raw[rgb_start + 1], raw[rgb_start + 2], opacity);+102
}+103
}+104
}+105
printf("CAPTURE bg-tolerance=2 near-white-tolerance=14 counts-white=%lu background=%lu total=%lu required-bg=%lu required-white=200 brightest=%d,%d,%d valid=%d\n",+106
white, background, width * height, (width * height * 3 + 3) / 4,+107
brightest[1], brightest[2], brightest[3], valid);+108
sw_appkit.pool_pop(pool);+109
if (!valid) return SIGIL_FALSE;+110
Value values[] = {sigil_fixnum((int64_t)white), sigil_fixnum((int64_t)background),+111
sigil_fixnum((int64_t)width), sigil_fixnum((int64_t)height)};+112
return sigil_array_create(vm, 4, values);+113
}+114
void sigil__init_drawing_tests(SigilVM *vm)+115
{+116
sigil__init_coretext_test_fixture(vm);+117
if (!sigil_begin_module(vm, "(drawing native)")) return;+118
sigil_module_register_native(vm, "capture-white-pixels", capture, SIGIL_ARITY_EXACT(0), "Compare raw cached pixels with profile-matched sRGB expectations");+119
sigil_module_export(vm, "capture-white-pixels");+120
sigil_end_module(vm);+121
}test/macos-drawing/package.sgladded
@@ -0,0 +1,37 @@
+1
;;; Reproducible integration fixture; pass accepted local candidate sources.+2
(import (only (sigil process) getenv))+3
(define font-source (getenv "SIGIL_MACOS_FONT_SOURCE"))+4
(define window-source (getenv "SIGIL_MACOS_WINDOW_SOURCE"))+5
(unless (and font-source window-source)+6
(error "Set SIGIL_MACOS_FONT_SOURCE and SIGIL_MACOS_WINDOW_SOURCE to accepted source directories"))+7
(define fixture (path-join font-source "test/coretext-host/native/fixture.c"))+8
(package+9
name: "sigil-font-ui-drawing-tests"+10
version: "0.0.0"+11
sigil: "0.24.8"+12
entry: '(drawing main)+13
dependencies: (list+14
(from-path name: "sigil/sigil-font" package: "sigil-font" dir: font-source)+15
(from-path name: "sigil/sigil-window" package: "sigil-window" dir: window-source)+16
(from-path name: "sigil/sigil-ui" package: "sigil-ui" dir: "../..")+17
(from-pkg name: "sigil/sigil-lib" version: "0.24.8")+18
(from-pkg name: "sigil/sigil-stdlib" version: "0.24.8"))+19
configs: (list+20
(config name: 'darwin-arm64 toolchain: 'zig target: "aarch64-macos.15.0-none"+21
features: '(cross darwin) c-flags: '("-DSIGIL_FONT_CORETEXT_TEST=1")+22
output-dir: "build/darwin-arm64"))+23
libraries: (list+24
(library name: 'sigil-font-ui-drawing-tests+25
c-sources: (list "native/capture.c" fixture)+26
native-init: "sigil__init_drawing_tests"))+27
tasks: (list+28
(task name: 'build steps: (list+29
(compile-c-sources sources: (list "native/capture.c" fixture)+30
include-dirs: (list (path-join window-source "native"))+31
flags: (with-sigil-c-flags '("-std=c11" "-Wall" "-Wextra" "-Werror")))+32
(create-static-library name: "sigil-font-ui-drawing-tests")+33
(compile-sigil-modules sources: "src/**/*.sgl"+34
output-dir: (config-output-subdir "lib"))+35
(compile-sigil-modules+36
sources: (list (path-join font-source "test/coretext-host/src/sigil/font/tests/fixtures.sgl"))+37
output-dir: (config-output-subdir "lib"))))))test/macos-drawing/src/drawing/main.sgladded
@@ -0,0 +1,47 @@
+1
(define-library (drawing main)+2
(import (sigil ui appkit) (sigil ui tree) (sigil ui theme) (sigil ui raster)+3
(sigil ui text) (sigil ui mask) (sigil font tests fixtures)+4
(drawing native) (sigil process) (sigil path) (sigil io) (sigil array))+5
(export main)+6
(begin+7
(define checks 0)+8
(define (check condition label)+9
(set! checks (+ checks 1))+10
(unless condition (error "Native UI drawing check failed" label))+11
(println "PASS: ~a" label))+12
(define (main)+13
(define args (cdr (command-line)))+14
(unless (and (= 2 (length args)) (%fixture-begin! (car args))) (exit 2))+15
(guard (failure (#t (println "FAIL: ~a" failure) (exit (%fixture-end! checks 1))))+16
;; First host open precedes NSApplication/WebKit/menu initialization.+17
(define window (open-appkit-window title: "Sigil font drawing qualification"+18
width: 320 height: 160 visible?: #f))+19
(define files (path-join (cadr args) "font/fixtures"))+20
(define font (make-text-font (path-join files "JetBrainsMono-Regular.ttf")+21
(path-join files "JetBrainsMono-Bold.ttf")+22
fallback-files: (list (path-join files "NotoSansSymbols2-Regular.ttf"))))+23
(dynamic-wind+24
(lambda () #f)+25
(lambda ()+26
(define ui (appkit-make-ui window (make-theme '() '() '()) #x123456))+27
(define canvas (ui-canvas ui))+28
(define scale (ui-scale ui))+29
(define damage (ui-update! ui (rect 0 0 320 160 #x123456)))+30
(check (= #x123456 (canvas-pixel canvas 4 4)) "retained rectangle rendered")+31
(draw-text! font canvas 12 12 "FgéλЖ ☃☑" 22 #xffffff scale: scale)+32
(check (> (canvas-count-other canvas 0 0 (canvas-width canvas) (canvas-height canvas) #x123456) 0)+33
"CoreText outlines changed real UI pixels")+34
(check (appkit-present-ui! window ui damage) "text/rectangle frame accepted by actual host")+35
(appkit-dispatch window 0)+36
(define captured (capture-white-pixels))+37
(check (and captured (>= (array-ref captured 0) 200)+38
(>= (* 4 (array-ref captured 1))+39
(* 3 (array-ref captured 2) (array-ref captured 3))))+40
"actual AppKit cache has at least 75% matched background and 200 near-white pixels")+41
(define overlay (make-canvas (canvas-width canvas) (canvas-height canvas) #xff0000))+42
(define alpha (make-mask (canvas-width canvas) (canvas-height canvas)+43
(make-bytevector (* (canvas-width canvas) (canvas-height canvas)) 128)))+44
(check (appkit-present-overlay! window overlay alpha) "actual host accepts A8 overlay")+45
(appkit-dispatch window 0))+46
(lambda () (text-font-close! font) (appkit-close! window)))+47
(exit (%fixture-end! checks 0))))))test/macos-drawing/src/drawing/native.sgladded
@@ -0,0 +1,3 @@
+1
(define-library (drawing native)+2
(export capture-white-pixels)+3
(begin (define-native (capture-white-pixels) (: -> any?))))test/macos/fixture-arguments.sgladded
@@ -0,0 +1,8 @@
+1
;;; Positional arguments after argv[0], shared by the launcher and Linux controls.+2
(define (fixture-arguments name run resources)+3
(cond+4
((member name '("host-aarch64" "appkit-conformance" "webkit-aarch64" "initialization-aarch64"))+5
(list run))+6
((member name '("font-aarch64" "ui-drawing-aarch64"))+7
(list run resources))+8
(else (error "Unknown qualification fixture" name))))test/macos/qualify.sgladded
@@ -0,0 +1,137 @@
+1
#!/usr/bin/env sigil+2
;;; Run sealed Linux-built fixtures locally on an arm64 Mac. Default mode+3
;;; checks all preconditions and leaves the filesystem unchanged.+4
(import (sigil shell prelude))+5
(requires (tools uname sw_vers shasum cp mkdir xattr))+6
(define packet (realpath (script-dir)))+7
(define destination (arg 1))+8
(define expected-manifest (arg 2))+9
(define mode (arg 3 default: "--plan"))+10
(unless (regex-match? "^[0-9a-f]{64}$" expected-manifest)+11
(error "Supply the independently recorded manifest SHA-256"))+12
(unless (member mode '("--plan" "--execute")) (error "Expected --plan or --execute"))+13
(unless (and (equal? (out uname -s) "Darwin") (equal? (out uname -m) "arm64"))+14
(error "Qualification requires an arm64 Mac"))+15
(define os-version (out sw_vers -productVersion))+16
(unless (>= (string->number (car (split os-version "."))) 15)+17
(error "Qualification requires macOS 15.0 or newer" os-version))+18
(unless (and (starts-with? destination "/")+19
(equal? destination (path-normalize destination))+20
(directory? (dirname destination))+21
(not (file-exists? destination)) (not (symlink? destination)))+22
(error "Supply a fresh absolute run directory with an existing parent" destination))+23
(define manifest (path packet "SHA256SUMS"))+24
(unless (equal? expected-manifest+25
(car (regex-split "\\s+" (out shasum -a 256 ,manifest))))+26
(error "Manifest differs from its independently supplied SHA-256"))+27
(define fixtures '("host-aarch64" "appkit-conformance" "webkit-aarch64" "initialization-aarch64"+28
"font-aarch64" "ui-drawing-aarch64"))+29
(define resources+30
'("font/fixtures/JetBrainsMono-Regular.ttf" "font/fixtures/JetBrainsMono-Bold.ttf"+31
"font/fixtures/NotoSansSymbols2-Regular.ttf" "font/fixtures/OFL.txt"+32
"font/fixtures/Noto-Symbols-OFL.txt" "font/fixtures/README.md" "font/fixtures/helpers.sgl"+33
"font/test/test-conformance.sgl" "font/test/test-coretext-lifetime.sgl"+34
"font/test/test-coretext-unicode.sgl"+35
"font/source/coretext.c" "font/source/coretext-runtime.c" "font/source/coretext-runtime.h"+36
"font/source/fixture.c" "font/source/coretext-main.sgl" "font/source/drawing-main.sgl"+37
"font/source/capture.c" "font/source/drawing-package.sgl"+38
"font/source/probe-support.h" "font/source/fixture-module.sgl"+39
"font/source/drawing-native.sgl" "font/source/coretext-package.sgl" "font/source/font-package.sgl"+40
"font/source/collection-support.h"))+41
(define names (append fixtures '("Info.plist" "qualify.sgl" "fixture-arguments.sgl") resources))+42
(define rows (filter (lambda (row) (not (string=? row "")))+43
(split (read-text manifest trim: #t) "\n")))+44
(unless (= (length rows) (length names)) (error "Qualification manifest is incomplete"))+45
(define seen '())+46
(define expected-hashes '())+47
(each row rows+48
(define match (regex-match "^([0-9a-f]{64}) ([A-Za-z0-9._/-]+)$" row))+49
(unless match (error "Invalid manifest row" row))+50
(define name (match-group match 2))+51
(unless (and (member name names) (not (member name seen)) (file? (path packet name)))+52
(error "Unexpected, duplicate or missing qualification input" name))+53
(set! seen (cons name seen))+54
(set! expected-hashes (cons (cons name (match-group match 1)) expected-hashes))+55
(unless (equal? (match-group match 1)+56
(car (regex-split "\\s+" (out shasum -a 256 ,(path packet name)))))+57
(error "Qualification input hash mismatch" name)))+58
(each name fixtures+59
(unless (positive? (bitwise-and (stat-mode (file-stat (path packet name))) #o100))+60
(error "Fixture is not executable (owner execute bit required)" name)))+61
(println "PASS: arm64 macOS ~a, externally pinned manifest, ~a exact hashes, fresh output directory"+62
os-version (length names))+63
(load (path packet "fixture-arguments.sgl"))+64
(println "PLAN: directly launch copied host/modal, Sigil, WK, initialization, font and UI bundle executables")+65
(println "PLAN: host/Sigil/WK/initialization receive RUN; font/UI receive RUN RESOURCES; retain actual process status")+66
(println "PLAN: copy pinned fonts/tests; process-only font registrations are cleaned up; verify exit/PID/hash")+67
(println "PLAN: automatically clear com.apple.quarantine only on newly copied scratch bundles before launch")+68
(println "PLAN: no compiler, SDK, signing, credentials or network access required")+69
(println "PLAN: retain independent fixture failures, continue through drawing, then fail the aggregate if needed")+70
(when (equal? mode "--execute")+71
($ mkdir -m 700 ,destination)+72
(define owned-resources (path destination "resources"))+73
(each name resources+74
(define copy (path owned-resources name))+75
(ensure-directory (dirname copy))+76
($ cp ,(path packet name) ,copy)+77
(unless (equal? (car (regex-split "\\s+" (out shasum -a 256 ,copy)))+78
(cdr (assoc name expected-hashes)))+79
(error "Scratch resource copy differs" name)))+80
($ xattr -dr com.apple.quarantine ,owned-resources)+81
(define outcomes '())+82
(each name fixtures+83
(define run (path destination name))+84
($ mkdir ,run)+85
(define contents (path run "Probe.app/Contents"))+86
(ensure-directory (path contents "MacOS"))+87
(define binary (path contents "MacOS/runtime-probe"))+88
($ cp ,(path packet name) ,binary)+89
(unless (positive? (bitwise-and (stat-mode (file-stat binary)) #o100))+90
(error "Copied fixture is not executable (owner execute bit required)" name))+91
($ cp ,(path packet "Info.plist") ,(path contents "Info.plist"))+92
(unless (equal? (car (regex-split "\\s+" (out shasum -a 256 ,(path contents "Info.plist"))))+93
(cdr (assoc "Info.plist" expected-hashes)))+94
(error "Copied bundle metadata differs from the pinned manifest" name))+95
($ xattr -dr com.apple.quarantine ,(path run "Probe.app"))+96
(define hash (car (regex-split "\\s+" (out shasum -a 256 ,binary))))+97
(unless (equal? hash (cdr (assoc name expected-hashes)))+98
(error "Copied executable differs from the pinned manifest" name))+99
;; Copy/pin failures above remain fatal. Independent fixture behavior+100
;; failures below are retained, then the remaining fixtures still run.+101
(guard (failure+102
(else+103
(define message (exception-message failure))+104
(write-text (path run "fixture.failure") (str message "\n"))+105
(set! outcomes (cons (cons name "FAIL") outcomes))+106
(println "FAIL: ~a: ~a" name message)))+107
;; Direct execution retains the fixture's real exit status. LaunchServices'+108
;; open -W reports its own success even when a fixture exits before START.+109
(define arguments (fixture-arguments name run owned-resources))+110
(define launched ($? ,binary ,@arguments timeout: 180))+111
(write-text (path run "launch.result") (format-outcome launched))+112
(write-text (path run "launch.stdout") (stdout-of launched))+113
(write-text (path run "launch.stderr") (stderr-of launched))+114
(define result (read-text (path run "runtime.result") missing: "" trim: #t))+115
(define result-match (regex-match "status=(\\d+) pid=(\\d+) sha256=([0-9a-f]{64})" result))+116
(define log-text (read-text (path run "runtime.log") missing: ""))+117
(define start (regex-search "START pid=(\\d+)\n" log-text))+118
(display log-text)+119
(display (stderr-of launched))+120
(display (read-text (path run "runtime.stderr") missing: ""))+121
(unless start+122
(error (format "FAIL: app exited with no START line (exit status ~a; ~a)"+123
(exit-status launched) (format-outcome launched)) name run))+124
(unless (and (ok? launched) start result-match+125
(equal? (match-group result-match 1) "0")+126
(equal? (match-group start 1) (match-group result-match 2))+127
(equal? hash (match-group result-match 3)))+128
(error "FAIL: fixture exit/PID/hash evidence did not match" name run))+129
(set! outcomes (cons (cons name "PASS") outcomes))+130
(println "PASS: ~a exact executable ~a exited with matching evidence" name hash)))+131
(write-text (path destination "qualification.result")+132
(str (string-join (map (lambda (entry) (str (car entry) " " (cdr entry)))+133
(reverse outcomes)) "\n") "\n"))+134
(unless (every (lambda (entry) (equal? (cdr entry) "PASS")) outcomes)+135
(error "FAIL: qualification fixtures failed; all fixtures attempted"+136
(reverse outcomes) destination))+137
(println "PASS: AppKit, CoreText and native UI drawing; evidence ~a" destination))