AtlatestRepositorysigil-fontconfig
sigil-fontconfig / tree / scriptsci-test.sgl
1
;;; Run isolation in a fresh process, then the suites that initialize defaults.2
(import (sigil shell prelude) (sigil fs))3
(requires (tools sigil gcc))4
(define root (dirname (script-dir)))5
(define profile (getenv "GUIX_ENVIRONMENT"))6
(define (xml text)7
(string-replace (string-replace (string-replace text "&" "&") "<" "<") ">" ">"))8
(define (profile-face names)9
(unless profile10
(error "Use guix shell -m manifest.scm or set SIGIL_FONTCONFIG_TEST_DIRECTORY"))11
(let find ((remaining names))12
(when (null? remaining) (error "The manifest lacks a required test face" names))13
(let ((candidate (path profile "share/fonts/truetype" (car remaining))))14
(if (file? candidate) candidate (find (cdr remaining))))))16
(with-temp-dir work17
(define inventory (or (getenv "SIGIL_FONTCONFIG_TEST_DIRECTORY") (path work "fonts")))18
(unless (getenv "SIGIL_FONTCONFIG_TEST_DIRECTORY")19
(ensure-directory inventory)20
(each entry '(("JetBrainsMono-Regular.ttf" "JetBrainsMono-Regular.ttf")21
("JetBrainsMono-Bold.ttf" "JetBrainsMono-Bold.ttf")22
("NotoSans.ttf" "NotoSans[wdth,wght].ttf" "NotoSans-Regular.ttf" "NotoSans.ttf")23
("NotoSerif.ttf" "NotoSerif[wdth,wght].ttf" "NotoSerif-Regular.ttf" "NotoSerif.ttf"))24
(copy-file (profile-face (cdr entry)) (path inventory (car entry)))))25
(each name '("JetBrainsMono-Regular.ttf" "JetBrainsMono-Bold.ttf" "NotoSans.ttf" "NotoSerif.ttf")26
(unless (file? (path inventory name)) (error "Missing owned test face" name)))27
(define context-cache (or (getenv "SIGIL_FONTCONFIG_TEST_CACHE") (path work "context-cache")))28
(define default-cache (path work "default-cache"))29
(define configuration (path work "fonts.conf"))30
(ensure-directory context-cache)31
(ensure-directory default-cache)32
(write-text configuration33
(str "<fontconfig><dir>" (xml inventory) "</dir><cachedir>"34
(xml default-cache) "</cachedir></fontconfig>"))35
(setenv! "SIGIL_FONTCONFIG_TEST_DIRECTORY" inventory)36
(setenv! "SIGIL_FONTCONFIG_TEST_CACHE" context-cache)37
(setenv! "FONTCONFIG_FILE" configuration)38
(setenv! "FONTCONFIG_PATH" work)39
(setenv! "FONTCONFIG_SYSROOT" #f)40
(setenv! "XDG_CACHE_HOME" default-cache)41
(when profile (setenv! "LD_LIBRARY_PATH" (path profile "lib")))42
(define abi (path work "value-abi.sgl"))43
($ gcc -std=c11 ,@(if profile (list "-I" (path profile "include")) '())44
,(path root "test/value-abi.c") -o ,(path work "value-abi") timeout: 30)45
($ ,(path work "value-abi") out: ,abi timeout: 5)46
(setenv! "SIGIL_FONTCONFIG_VALUE_ABI" abi)47
(println "Fontconfig CI: fresh-process isolation first")48
($ sigil test test/test-00-isolation.sgl cwd: ,root49
env: ,(dict "SIGIL_FONTCONFIG_ISOLATION_FIRST" "1") timeout: 900)50
(println "Fontconfig CI: legacy and owned-context suites")51
($ sigil test test/test-fontconfig.sgl test/test-context.sgl cwd: ,root timeout: 900)52
($ sigil test test/test-value-abi.sgl cwd: ,root timeout: 900))