Commitcafef7d9Recorded31 Jul 2026Repositorysigil
test(shell): port integration gates as demonstrations
Changed
packages/sigil-shell/test/test-requires.sgl | 7 +++++--
test/integration/test-env-channel-direct-source.sgl | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/integration/test-native-uncaught-error.sgl | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 188 insertions(+), 2 deletions(-)Diff
packages/sigil-shell/test/test-requires.sglmodified
@@ -38,9 +38,12 @@
38
(test "unknown clauses fail closed" 39
(let ((message 40
(guard (exn (else (exception-message exn)))−41
(requires (tools sh) (net localhost))+41
(requires (tools true) (net localhost)) 42
"")))−43
(assert-true (string-contains? message "unknown requires clause: net"))))+43
(assert-true (string-contains? message "unknown requires clause: net"))+44
;; Validation covers the complete clause vocabulary before any earlier+45
;; tools clause can mutate the registry.+46
(assert-error (tool-path 'true)))) 47
48
(test "malformed requirement lists fail closed" 49
(assert-error (requires))))test/integration/test-env-channel-direct-source.sgladded
@@ -0,0 +1,112 @@
+1
#!/usr/bin/env sigil+2
;;; Demonstration port of test-env-channel-direct-source.sh.+3
;;; This is a library test, not a release gate. The Bash sibling remains+4
;;; authoritative until a release containing (sigil shell) has shipped.+5
+6
(import (sigil env manifest)+7
(sigil env snapshot)+8
(sigil fs)+9
(sigil path)+10
(sigil process)+11
(sigil shell)+12
(sigil shell checks)+13
(sigil store)+14
(sigil string))+15
+16
(requires (tools minisign))+17
+18
(define repo-root+19
(realpath (path-dirname (path-dirname (script-dir)))))+20
(define scratch (make-temp-directory))+21
(define channel (and scratch (path-join scratch "channel")))+22
(define cache (and scratch (path-join scratch "cache")))+23
(define registry-metadata+24
(path-join repo-root "test/fixtures/registry-trust/registry.json"))+25
(define source-hash #f)+26
(define evaluated-environment #f)+27
+28
(define (delete-tree path)+29
(when (and path (file-exists? path))+30
(if (directory? path)+31
(begin+32
(for-each+33
(lambda (entry) (delete-tree (path-join path entry)))+34
(directory-list path))+35
(delete-directory path))+36
(delete-file path))))+37
+38
(check "SGLSH-S19-direct-source-evaluates"+39
(unless scratch (error "could not create a temporary directory"))+40
(let* ((packages-dir (path-join channel "src/core/packages"))+41
(snapshot (path-join channel "snapshot.sgl"))+42
(secret-key+43
(path-join repo-root+44
"test/fixtures/registry-signing-test-key/channels-test.key"))+45
(toolchain-recipe (hash-data "toolchain-recipe"))+46
(toolchain-output (hash-data "toolchain-output")))+47
(ensure-directory packages-dir)+48
(ensure-directory cache)+49
(write-file-string+50
(path-join packages-dir "wasm.sgl")+51
(string-append+52
"(define-library (core packages wasm)\n"+53
" (import (sigil core) (sigil env authoring))\n"+54
" (export direct-environment)\n"+55
" (begin\n"+56
" (define (direct-environment)\n"+57
" (environment packages: '()))))\n"))+58
(write-file-string+59
(path-join scratch "env.sgl")+60
"(import (core packages wasm))\n(direct-environment)\n")+61
(set! source-hash (hash-directory (path-join channel "src")))+62
(let* ((content+63
(string-append+64
"(snapshot-content schema: 1 id: \"direct-source\" sequence: 1)\n"+65
"(toolchain id: \"toolchain/zig\" version: \"test\" recipe: \"sha256:"+66
toolchain-recipe "\" output: \"sha256:" toolchain-output "\")\n"+67
"(pkg id: \"core/packages/wasm\" version: \"0.1.0\" recipe: \"sha256:"+68
source-hash "\")\n"))+69
(content-hash (hash-data content)))+70
(write-file-string+71
snapshot+72
(string-append+73
"(snapshot schema: 1 id: \"direct-source\" sequence: 1 content-hash: \"sha256:"+74
content-hash "\")\n"+75
"(toolchain id: \"toolchain/zig\" version: \"test\" recipe: \"sha256:"+76
toolchain-recipe "\" output: \"sha256:" toolchain-output "\")\n"+77
"(pkg id: \"core/packages/wasm\" version: \"0.1.0\" recipe: \"sha256:"+78
source-hash "\")\n")))+79
($ minisign -S -W -s ,secret-key -m ,snapshot+80
-t "registry=pkg.usesigil.org path=/v1/channels/direct-source/snapshot.sgl seq=201 ts=2026-07-28T00:01:00Z")+81
(setenv! "XDG_CACHE_HOME" cache)+82
;; Native bundles initialize registry trust before script top-level, so+83
;; the caller must set this before starting Sigil, as the Bash gate does.+84
(unless (equal? (getenv "SIGIL_REGISTRY_METADATA") registry-metadata)+85
(error+86
(format "run with SIGIL_REGISTRY_METADATA=~a" registry-metadata)))+87
(set! evaluated-environment+88
(evaluate-environment-program+89
(path-join scratch "env.sgl")+90
channel+91
(read-verified-snapshot snapshot 0)+92
(or (getenv "SIGIL") (path-join repo-root "build/dev/bin/sigil"))+93
'()))))+94
+95
(check "SGLSH-S19-direct-source-manifest-contains-wasm"+96
(unless (and evaluated-environment+97
(pair? (cdr evaluated-environment))+98
(string=? (format "~a" (car (cadr evaluated-environment)))+99
"core/packages/wasm")+100
(string=? (format "~a" (cadr (cadr evaluated-environment)))+101
"0.1.0"))+102
(error (format "manifest does not contain core/packages/wasm 0.1.0: ~a"+103
evaluated-environment))))+104
+105
(check "SGLSH-S19-direct-source-hash-is-stable"+106
(unless (equal? (authoring-channel-source-hash channel) source-hash)+107
(error "authoring source hash diverged from hash-directory")))+108
+109
(check "SGLSH-S19-direct-source-cleans-up"+110
(delete-tree scratch))+111
+112
(run-checks!)test/integration/test-native-uncaught-error.sgladded
@@ -0,0 +1,71 @@
+1
#!/usr/bin/env sigil+2
;;; Demonstration port of test-native-uncaught-error.sh.+3
;;; This is a library test, not a release gate. The Bash sibling remains+4
;;; authoritative until a release containing (sigil shell) has shipped.+5
+6
(import (sigil fs)+7
(sigil path)+8
(sigil process)+9
(sigil shell)+10
(sigil shell checks)+11
(sigil string))+12
+13
(requires (tools file))+14
+15
(define repo-root+16
(realpath (path-dirname (path-dirname (script-dir)))))+17
(define sigil-bin+18
(or (getenv "SIGIL") (path-join repo-root "build/dev/bin/sigil")))+19
(define app-dir+20
(path-join (script-dir) "apps/native-uncaught-probe"))+21
(define bin+22
(path-join app-dir "build/release/bin/native-uncaught-probe"))+23
(define with-zig (path-join repo-root "scripts/with-zig"))+24
(define probe-outcome #f)+25
(define probe-output "")+26
+27
(define (delete-tree path)+28
(when (file-exists? path)+29
(if (directory? path)+30
(begin+31
(for-each+32
(lambda (entry) (delete-tree (path-join path entry)))+33
(directory-list path))+34
(delete-directory path))+35
(delete-file path))))+36
+37
(check "SGLSH-S19-native-probe-builds"+38
(unless (and (file? sigil-bin) (command-exists? sigil-bin))+39
(error (format "sigil binary is missing or not executable: ~a" sigil-bin)))+40
(delete-tree (path-join app-dir "build"))+41
(if (and (file? with-zig) (command-exists? with-zig))+42
($ ,with-zig ,sigil-bin build --config release cwd: ,app-dir)+43
($ ,sigil-bin build --config release cwd: ,app-dir))+44
(unless (and (file? bin) (command-exists? bin))+45
(error (format "native binary was not produced: ~a" bin))))+46
+47
(check "SGLSH-S19-native-probe-is-ELF"+48
(unless (string-contains? (out file ,bin) "ELF")+49
(error (format "native probe is not an ELF binary: ~a" bin))))+50
+51
(check "SGLSH-S19-native-uncaught-error-is-a-considered-failure"+52
(set! probe-outcome ($? ,bin err: 'merge timeout: 30))+53
(set! probe-output (stdout-of probe-outcome))+54
(display probe-output)+55
(unless (failed? probe-outcome)+56
(error (format "probe did not exit with a considered failure: ~a"+57
(format-outcome probe-outcome)))))+58
+59
(check "SGLSH-S19-native-code-before-raise-ran"+60
(unless (string-contains? probe-output "before-raise")+61
(error "code before the raise did not run")))+62
+63
(check "SGLSH-S19-native-error-surfaced"+64
(unless (string-contains? probe-output "uncaught-boom")+65
(error "uncaught exception was swallowed")))+66
+67
(check "SGLSH-S19-native-code-after-raise-did-not-run"+68
(when (string-contains? probe-output "REACHED-END")+69
(error "execution continued past the uncaught raise")))+70
+71
(run-checks!)