louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
ADR 0064: Test-only code: @test import, [dev-dependencies], and gen
Status: Proposed (2026-10-27); needs engineering review (#44), in particular dropping tests from program builds (what a build no longer checks), louise check loading test/, and unused imports being reported only where the tests are seen.
Context
An inline test could not use a package's test/ modules: louise build loads only src/, so the import would fail the build. toki2 forbids it by rule, and its test helpers ended up in production files below the first @test, copied from module to module. A package could not depend on another for its tests only either: [dependencies] are built and linked with the program, and louise.toml rejected any other table. @test functions themselves were type-checked and lowered by every command and merely never used as entries.
Rust answers with #[cfg(test)] and [dev-dependencies]; Louise had neither. There was also no way to write randomized tests beyond std/random.
Decision
@test import m imports m for tests only.
louise test,louise checkand the language server resolve it, and only@testfunctions may use it: any other item that does is E0126, reported once, at the item.- A program build (
build,run,core) leaves out every@testfunction and@test importbefore names are resolved. What only tests use is neither checked nor compiled, and atest/module can be imported, since only the analyses that loadtest/see the import. - A
@test importdoes not count toward import cycles (E0105). Only@testfunctions use it, so no interface depends on it, and a module's tests may use a helper undertest/that imports the module itself (a domain module's tests and its fixtures). Inference orders functions by their references, not modules, so nothing else needs the edge. - No other attribute applies to an import (E0114).
louise fmtkeeps@teston the import's line and sorts@test imports after the plain ones of their run.
Unused imports (W0102) are reported only where the tests are seen. Without them, an import used only by a test looks unused, so program builds no longer report W0102; check, test and the language server do.
louise check loads test/, and still checks [application]. Before, it checked src/ only.
[dev-dependencies] in louise.toml (the root package's only) are resolved and locked like [dependencies], so a build and a test run agree on louise.lock.
- They are loaded by
test,checkand the language server, and left out of program builds (Resolution::without_dev): not loaded, not linked. - A package reachable both ways is an ordinary dependency. A name may not be in both tables.
louise test --native reports a multi-line panic message whole, as the interpreter does (it kept the first line).
gen (packages/gen) is a package for randomized tests, taken as a dev-dependency:
gen: generators. A generator is anyfn() -> a / <random>: therandomeffect plays the part a generator monad plays elsewhere, sequencing is ordinary code, andrandom.with_seedmakes a run repeatable. Every generator draws so that zero bytes give its smallest value.gen/fake: words, sentences, names, emails and URLs.gen/check:property,seededandcounterexample. A case runs under a handler ofrandomthat records its bytes; a failing case's bytes are shrunk (blocks deleted, blocks zeroed, bytes made 0, halved or one less) while the generator, replaying them under another handler, still makes a failing case, as Hypothesis does. No type needs a shrinker of its own.propertytakes its seed fromrandom, so each test run tries new cases, and a failure names the seed to replay.
Consequences
- An inline test can use helpers kept under
test/, and a package's test-only dependencies stay out of its builds. - A program build no longer type-checks its tests.
louise checkandlouise testdo, and CI runs both. - Older compilers reject
[dev-dependencies]and@test import, so a package that uses them must requirelouise = ">= 0.3.0". louise checkreports problems intest/that it did not see before.- Handlers are lexical (ADR 0010), so generators cannot be kept in data.
genchooses between values (pick,weighted), not between generators. - Shrinking needs generators that draw through
random. One that keeps its own state, or ignores the bytes it draws, does not shrink well. - Not done: shrinking within a time budget, a database of past failures, generators derived from types.