AtlatestRepositorysigil-ui
1
#!/usr/bin/env sigil2
;; Usage: HEADERS ARCHIVE EVIDENCE [PRIOR-WAYLAND-C]. The optional prior3
;; source must fail early-close, close/configure and expired-pending checks.4
;; Run the bytecode suite first to build the wrapper's font and FFI dependencies.5
(import (sigil shell prelude))6
(define root (realpath (path (script-dir) "..")))7
(define headers (arg 1))8
(define archive (arg 2))9
(define evidence (arg 3))10
(define prior-source (arg 4 default: #f))11
(define compiler (or (getenv "CC") "cc"))12
(unless (and (file? (path headers "sigil/sigil.h")) (file? archive)13
(or (not prior-source) (file? prior-source)))14
(error "Expected matching runtime headers/archive and an optional prior source"))15
(ensure-directory evidence)16
(define flags (list "-std=c11" "-D_GNU_SOURCE" "-O1" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter"17
(str "-I" headers) (str "-I" (path root "native"))18
(str "-I" (path root "native/wayland")) (str "-I" (path root "native/wayland/include"))))19
(define fixture (path root "test/wayland/configure-peer.c"))20
(define sources (map (lambda (file) (path root "native" file))21
'("raster.c" "png.c" "surface-unavailable.c")))22
(define font-archives23
(map (lambda (file) (path root "build/dev/native" file))24
'("libsigil-font.a" "libsigil-ffi.a")))25
(unless (every file? font-archives)26
(error "Run sigil test --backend bytecode to build the font and FFI archives"))27
(define source-root (path root "src"))28
(define wayland-module (path source-root "sigil/ui/wayland.sgl"))29
(define font-paths30
(map (lambda (name) (path root ".sigil/deps/sigil" name "src"))31
'("sigil-font" "sigil-freetype" "sigil-fontconfig" "sigil-ffi")))32
(define fixed (path evidence "configure-peer"))33
($ ,compiler ,@flags ,fixture ,@sources ,@font-archives ,archive -lm -ldl -lpthread -o ,fixed34
out: ,(path evidence "configure-compile.log") err: 'merge timeout: 40)35
(each case '("early-close" "close-configure" "traffic" "expired-pending" "activation" "activation-removed")36
(define log (path evidence (str "configure-" case ".log")))37
($ ,fixed ,case ,wayland-module ,source-root ,@font-paths ,@(library-paths)38
out: ,log err: 'merge timeout: 15)39
(display (read-text log))40
(unless (contains? (read-text log) (str "PASS: configure peer " case))41
(error "Configure control did not report its intended result" case)))42
(when prior-source43
(define text (read-text fixture))44
(unless (contains? text "../../native/wayland.c") (error "Configure fixture include marker absent"))45
(define source (path evidence "configure-peer-prior.c"))46
(write-text source (string-replace text "../../native/wayland.c" (realpath prior-source)))47
(define prior (path evidence "configure-peer-prior"))48
($ ,compiler ,@flags ,(str "-I" (path root "test/wayland"))49
-include xdg-activation-v1-client-protocol.h ,source50
,@sources ,@font-archives ,archive -lm -ldl -lpthread -o ,prior51
out: ,(path evidence "configure-prior-compile.log") err: 'merge timeout: 40)52
(each case '("early-close" "close-configure" "expired-pending")53
(define log (path evidence (str "configure-baseline-" case ".log")))54
(define result ($? ,prior ,case out: ,log err: 'merge timeout: 15))55
(display (read-text log))56
(unless (and (not (ok? result)) (contains? (read-text log) (str "FAIL: configure peer " case)))57
(error "Prior source did not reproduce the configure regression" case))))58
(println "PASS: configure close, traffic wall deadline, expired-pending and activation controls")