jolt/test/integration/jank-conformance-test.janet
Yogthos 0e3584884f core: AOT context image — init-cached recovers the bootstrap cost across processes
init in compile mode is ~2.4 s (tier loading, analyzer self-compile, macro
recompilation), paid by every process that builds a ctx from source — each
jpm-test file, embedders, workers. init-cached marshals the built ctx to a
disk image (same root-env dicts as snapshot/fork) and later processes
unmarshal it in ~5 ms, any process: nothing from the baking process is
needed at load.

The cache key fingerprints the embedded .clj stdlib (which covers jolt-core:
analyzer, IR, core tiers), the .janet seed sources next to the module, the
janet version, the init opts, and the env knobs that shape a ctx (JOLT_PATH/
MUTABLE/AOT_CORE/FEATURES) — any change rebuilds. Corrupt or non-ctx images
fall back to a rebuild (unmarshal of garbage can 'succeed' with a scalar, so
the shape is checked, not just the throw). Writes are atomic (tmp + rename)
so racing cold starts never publish a torn image. JOLT_NO_IMAGE_CACHE=1
opts out; JOLT_IMAGE_CACHE_DIR overrides the location (default TMPDIR).

Test consumers switch to init-cached (harness, suite-worker, conformance,
the behavioral unit/integration tests); tests that validate the bootstrap
itself (bootstrap-fixpoint, staged-bootstrap, aot round-trip, direct-linking)
and the deps tests (tmp-dir :paths would fragment the key) keep real init.
Full jpm test: 2:46 -> 1:58 (~29%). New ctx-image-test covers cold/warm,
cross-process load (subprocess runs defn/redef/macros/protocols/multimethods
off the baked image), per-opts keying, and corrupt-image fallback.
2026-06-10 13:57:37 -04:00

54 lines
2.3 KiB
Text

# jank conformance: runs the Clojure-language pass-tests from a local jank
# checkout (https://github.com/jank-lang/jank, MPL-2.0) against Jolt and asserts
# the number that pass stays at/above a baseline. This does NOT vendor jank's
# sources (license differs) — it references ~/src/jank if present and SKIPS
# cleanly when absent, so it is a local/dev regression aid.
#
# Each jank pass-test is an assertion script ending in `:success`. We load it in
# a fresh context and count it as passing when it returns :success.
(use ../../src/jolt/api)
(def jank-dir (string (os/getenv "HOME") "/src/jank/compiler+runtime/test/jank"))
# Baseline: the number of pass-tests Jolt currently handles. Raise this as Jolt
# gains features so regressions (a previously-passing test breaking) are caught.
(def baseline 120)
# Tests that loop forever under Jolt's eager evaluation (skipped to avoid hangs;
# tracked as known gaps — variadic-recur arity selection and var-quote calls).
(def skip-patterns ["/cpp/" "var-quote" "fn/recur/pass-variadic-position"])
(defn- skip? [path]
(var s false)
(each p skip-patterns (when (string/find p path) (set s true)))
s)
(defn- walk [dir acc]
(each e (os/dir dir)
(def p (string dir "/" e))
(case ((os/stat p) :mode)
:directory (walk p acc)
:file (when (and (string/has-suffix? ".jank" p)
(string/find "/pass-" p)
(not (skip? p)))
(array/push acc p))))
acc)
(if (not (os/stat jank-dir))
(print "jank-conformance: ~/src/jank not present — skipped")
(do
(def files (sort (walk jank-dir @[])))
(var pass 0)
(def fails @[])
(each f files
# A pass-test passes when no assertion throws (assert now errors on failure).
(def res (protect (load-string (init-cached) (slurp f))))
(if (= (res 0) true)
(++ pass)
(array/push fails (string/slice f (+ 1 (length jank-dir))))))
(printf "jank-conformance: %d/%d pass-tests pass (baseline %d)" pass (length files) baseline)
(when (< pass baseline)
(print "--- regressions (now failing, were within baseline) ---")
(each rel fails (print " " rel))
(error (string "jank conformance dropped to " pass " (baseline " baseline ")")))
(printf "jank conformance OK (%d known gaps)" (length fails))))