Cairn.Fuzz.Collect
lean/Cairn/Fuzz/Collect.lean
fuzz_targets%: every fuzzable app, found at compile time
Elaborates to a List Cairn.Fuzz.Target, one per Machine declared in an app module (appModule: an app package's own) of
the imported environment. For each machine it collects, from the claim registry and the
environment:
- the
Appof the same state type declared in the machine's module (preferring<ns>.app); - the keyed moves of the machine's namespace;
- the invariants stated against it, with their
checkwheninvariantgenerated one; - every claim the module declares;
<ns>.fuzz : Cairn.Fuzz.Custom S, if the app defines one.
So an app needs no fuzz code: importing it from its lean_exe fuzz root is enough (Cairn's
test/fixture/lean/FuzzMain.lean). Compile time only
(imports Lean); the fuzz executable is the only thing that uses it.
Whose machines. A machine whose module is in the fuzz executable's own Lake package (the
package Lake builds the root in) is the package's: its target is named after its module's last
component (Fixture, Claims), with the machine's name added when the module declares several
(Gallery.machine). A machine of a dependency (cairn_atproto's session, imported by an app) is
collected too, marked dependency, and named with its package first: cairn_atproto/Claims.
lake exe fuzz runs only the package's own unless asked (--deps, docs/fuzz.md). Two targets
with one name are an error here, never one shadowing the other (cairn#221).
Imports Lean, Lean.Compiler.ModPkgExt, Cairn.Claims.Registry, Cairn.Fuzz.Target
Structures 1
Found : Type
A machine as fuzz_targets% names it.
machine : Lean.Namemodule : Lean.Namepackage : Option StringIts Lake package, if Lake named one.
inModule : NatHow many machines its module declares.
Definitions 8
rel (ns n : Lean.Name) : String
n relative to namespace ns, as source text.
last (n : Lean.Name) : String
moduleOf (env : Lean.Environment) (n : Lean.Name) : Option Lean.Name
appModule (m : Lean.Name) : Bool
Modules that hold apps: anything but Cairn itself and Lean's libraries, so an app package's
modules (Fixture.*, Yap.*) and its dependencies' (CairnAtproto.*).
constsOfType (env : Lean.Environment) (head : Lean.Name) : Array (Lean.Name × Lean.ConstantInfo)
Constants of app modules (appModule) whose type's head is head.
packageOf (env : Lean.Environment) (n : Lean.Name) : Option String
The Lake package of the module m was declared in (fixture, cairn_atproto), if Lake
named one; for the module being elaborated, its own.
names (own : Option String) (found : Array Found) : Except String (Array (String × Bool))
The target names of found, in order, with whether each is a dependency's, for the fuzz
executable built in package own: a machine of own is named after its module's last component
(and the machine's, when its module has several); a dependency's has its package (or, if Lake
named none, its module's root) and / in front. A name given twice is an error naming both
machines.
«termFuzz_targets%» : Lean.ParserDescr