Cairn · module

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 App of 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 check when invariant generated 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

Order

Structures 1

structure

Cairn.Fuzz.Collect.Found

lean/Cairn/Fuzz/Collect.lean:67
Found : Type

A machine as fuzz_targets% names it.

Fields
machine : Lean.Name
module : Lean.Name
package : Option String

Its Lake package, if Lake named one.

inModule : Nat

How many machines its module declares.

Definitions 8

def

Cairn.Fuzz.Collect.rel

lean/Cairn/Fuzz/Collect.lean:34
rel (ns n : Lean.Name) : String

n relative to namespace ns, as source text.

def

Cairn.Fuzz.Collect.last

lean/Cairn/Fuzz/Collect.lean:37
last (n : Lean.Name) : String
def

Cairn.Fuzz.Collect.moduleOf

lean/Cairn/Fuzz/Collect.lean:41
moduleOf (env : Lean.Environment) (n : Lean.Name) : Option Lean.Name
def

Cairn.Fuzz.Collect.appModule

lean/Cairn/Fuzz/Collect.lean:46
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.*).

def

Cairn.Fuzz.Collect.constsOfType

lean/Cairn/Fuzz/Collect.lean:50
constsOfType (env : Lean.Environment) (head : Lean.Name) :
  Array (Lean.Name × Lean.ConstantInfo)

Constants of app modules (appModule) whose type's head is head.

def

Cairn.Fuzz.Collect.packageOf

lean/Cairn/Fuzz/Collect.lean:61
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.

def

Cairn.Fuzz.Collect.names

lean/Cairn/Fuzz/Collect.lean:80
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.

def

Cairn.Fuzz.Collect.«termFuzz_targets%»

lean/Cairn/Fuzz/Collect.lean:94
«termFuzz_targets%» : Lean.ParserDescr