# `Rho.Dyn.Selftest`
[🔗](https://github.com/GenericJam/rho/blob/v0.1.0/lib/rho/dyn/selftest.ex#L1)

Selftests a compiled generation (the end of the pipeline's step 2, see `Rho.Dyn`),
one module at a time, each in a fresh process with a `max_heap_size`
(killed when exceeded, off-heap binaries included), a timeout and
`trap_exit` (a linked helper that crashes doesn't take the test down
unreported).

  * a **tool** (`Rho.Tool`) must name itself (`[a-z][a-z0-9_]*`),
    describe itself, declare a parameter schema and pass its `c:Rho.Tool.selftest/0`,
    which a Dyn tool must define;
  * a **screen** (the host's `c:Rho.Dyn.Screens.screen?/1`) must pass the
    host's screen test (`c:Rho.Dyn.Screens.selftest/1`; mob's mounts it
    on a test socket and renders a view tree);
  * any other module just has to have loaded.

Any module that also exports `selftest/0` gets it run too (`:ok` passes).
When the test process finishes, processes linked to it go down with it.
A failure is formatted inside the test process (`Rho.Untrusted.format/4`)
and the caller only takes strings back; a test process that dies
otherwise is described, not formatted (`Rho.Untrusted.exit_text/2`).

# `kind`

```elixir
@spec kind(module()) :: Rho.Dyn.Generation.kind()
```

The kind a loaded module is filed under.

# `run`

```elixir
@spec run([module()], keyword()) ::
  {:ok, [Rho.Dyn.Generation.selftest()]}
  | {:error, [Rho.Dyn.Generation.selftest()]}
```

Runs every module's test; `{:ok, results}` only if all passed. Options:
`:selftest_timeout_ms` (5000), `:selftest_max_heap_mb`
(64). Each result carries the
tool's `name` (nil for other kinds).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
