Decision 1. Odin's #load and #load_directory are the model, spelled as ordinary named calls — an s-expression language already has a head position and does not need Odin's `#`. (embed "p") is a [u8], (embed "p" string) is a string, and (embed-dir "d") is a [n EmbedFile] sorted by name. Two spellings rather than one that changes type with its context. Odin threads a type_hint everywhere and can afford it; with structural equality and no implicit widening, the same text meaning two types here would be a wart. The path is a literal and resolves relative to the file the form is written in, both of which are Odin's rules and for Odin's reasons: the bytes must be in hand before any value exists, and a package's assets must not depend on where flan was invoked from. The bytes reach the program as a [Str] node typed [u8], not as a [Bytes] prim over a string. [Bytes] is identity — emit.ml lowers String and Slice _ to the same %slice — and wrapping the literal in a prim would make the node non-constant, so an (embed-dir) bound with defconst could not be an LLVM constant. Both string emitters take the bytes and ignore the node's type, so it is the same constant either way and one a global can hold. emit.ml's escape is byte-exact, so a PNG survives the .ll. The directory lookup is a linear scan in the prelude over a slice of EmbedFile. A directory embed is tens of entries out of cache-warm .rodata, and a compile-time perfect hash would be a build-time map with its own failure modes that nothing has asked for. Sorted because readdir order is filesystem-dependent and an unsorted embed would make two builds of identical sources emit different .ll. The slice points into .rodata, so a store through it segfaults at -O0 and is deleted at -O2 — the same measured trap the prelude's ASCII-case note describes for (bytes "Hi"). Inherited, not widened; clone into a Vec for a mutable copy.
92 lines
4.3 KiB
Plaintext
92 lines
4.3 KiB
Plaintext
(tests
|
|
(names test_flan test_acceptance test_reload test_agent test_session test_dev test_emacs test_repl test_cider)
|
|
; Explicit because test_sanitize lives in this directory and is not one of
|
|
; these: two stanzas in one directory have to say which modules are whose.
|
|
; watchdog is every binary's clock: a hanging test reports nothing, so each
|
|
; of these arms an alarm that turns "for ever" into a failing run.
|
|
(modules test_flan test_acceptance test_reload test_agent test_session
|
|
test_dev test_emacs test_repl test_cider watchdog)
|
|
(libraries flan unix)
|
|
; The acceptance programs are part of the test corpus: if the reader, the
|
|
; parser or the checker regresses on them we want to know here, not at the CLI.
|
|
(deps
|
|
(file %{workspace_root}/calc-me.flan)
|
|
(file %{workspace_root}/sand.flan)
|
|
; The raylib bindings, because sand.flan and the FFI case import them and an
|
|
; import reads the directory at build time. sand.flan itself is above: the
|
|
; headless case imports it as a single-file package.
|
|
(glob_files %{workspace_root}/vendor/raylib/*)
|
|
; The dev agent package: its Flan declarations and the C that implements them.
|
|
(glob_files %{workspace_root}/vendor/agent/*)
|
|
; The EDN tokenizer, which programs/edn.flan imports.
|
|
(glob_files %{workspace_root}/vendor/edn/*)
|
|
; The ported raylib examples. Only one of them has a headless acceptance
|
|
; case, but it imports its example as a package and that example imports
|
|
; examples/digits.flan, so the directory has to be here whole.
|
|
(glob_files %{workspace_root}/examples/*)
|
|
(glob_files programs/*.flan)
|
|
; The files programs/embed.flan bakes in. An embed reads them at *compile*
|
|
; time, so they are a dependency of the checker run and not of the program.
|
|
(glob_files programs/assets/*)
|
|
; The reload primitive's host: a C main that dlopens what Build.shared made.
|
|
(file reload_host.c)
|
|
; A shared object that is not a redefinition module, for the agent's refusal
|
|
; path. Its destructor is what proves the handle was closed rather than lost.
|
|
(file noinstall.c)
|
|
; The other C main: flan_dev.c's two fixed limits, which no Flan program
|
|
; reaches, driven directly.
|
|
(file dev_limits.c)
|
|
; test_dev runs the compiler itself: flan dev launches and owns a program.
|
|
(file %{workspace_root}/bin/main.exe)
|
|
; The Emacs client, which test_emacs drives against a real daemon.
|
|
(glob_files %{workspace_root}/emacs/*.el)
|
|
; The WASI host the wasm32 case runs its module under, when no wasmtime or
|
|
; wasmer is installed.
|
|
(file wasm-run.mjs)))
|
|
|
|
; The web target, in its own stanza rather than in the table above because it
|
|
; is the one case whose toolchain is a separate install: emscripten, and a
|
|
; raylib archive built by vendor/raylib/build-web.sh. It probes for both and
|
|
; skips with the reason, so it is green on a machine that has neither.
|
|
(test
|
|
(name test_web)
|
|
(modules test_web)
|
|
(libraries flan unix)
|
|
(deps
|
|
(glob_files programs/*.flan)
|
|
(glob_files programs/assets/*)
|
|
; The raylib bindings and the ported example the raylib case builds. The
|
|
; example imports examples/digits.flan, so the directory comes whole.
|
|
(glob_files %{workspace_root}/vendor/raylib/*)
|
|
(glob_files %{workspace_root}/examples/*)
|
|
; flan run --target=web is refused by the CLI, so the CLI has to be here.
|
|
(file %{workspace_root}/bin/main.exe)))
|
|
|
|
; The corpus a second time under ASan and UBSan. Its own alias and not part of
|
|
; `dune test`: a sanitized build is a statically linked 1.8MB binary that takes
|
|
; tens of seconds to produce, so the sweep is minutes against the existing
|
|
; suite's seconds, and a test nobody will wait for is a test nobody runs.
|
|
;
|
|
; dune build --root . @sanitize
|
|
; An executable plus a rule rather than a (test ...): a test stanza attaches
|
|
; to the @runtest alias and offers no way to be attached to another one, which
|
|
; is the whole point here.
|
|
(executable
|
|
(name test_sanitize)
|
|
(modules test_sanitize watchdog)
|
|
(libraries flan unix))
|
|
|
|
(rule
|
|
(alias sanitize)
|
|
(deps
|
|
test_sanitize.exe
|
|
(file %{workspace_root}/calc-me.flan)
|
|
(file %{workspace_root}/sand.flan)
|
|
(glob_files %{workspace_root}/vendor/raylib/*)
|
|
(glob_files %{workspace_root}/vendor/agent/*)
|
|
(glob_files %{workspace_root}/vendor/edn/*)
|
|
(glob_files %{workspace_root}/examples/*)
|
|
(glob_files programs/*.flan)
|
|
(glob_files programs/assets/*))
|
|
(action (run ./test_sanitize.exe)))
|