Rho module registry rho-test 0.1.0

rho-test

The test runner. A test is an ordinary Rho program, so it runs on one backend:
whatever the project generates.

rho test <project-dir>
rho test --target go <project-dir>

What it does

  1. Discovers the tests under tests/.
  2. Builds the project.
  3. Runs the generated binary for each one.
  4. Reports each test, with the file and the line a failure is on.
module tests.option_test

import std.core.option

test "Some holds a value" {
    let value = Some(7)
    assert(is_some(value))
}

A failure reports the file, the line and what it expected. A test that says only
"failed" is a test nobody acts on.

Targets

TargetWhat it runs
cThe native build, which is the default
goThe Go backend, which is what most projects generate

Plugins

A test run is read by machines. A CI system wants a document it can parse rather
than a line it has to read, and none of that belongs in a runner that knows how
to run a test. So the runner offers two hooks and lets a plugin answer them:

HookWhen it runsWhat a plugin answers with
discoverOnce, over the test files the run foundFiles to add, so a plugin that knows a project's own test layout takes part in the run
runOnce, over the results of a finished runA report to write and notes to print

A plugin is attached to the runner rather than free-floating: it names the
component it extends and the hooks of it it answers, and validation checks that
relation before it is published.

extends: rho-test
hooks: [run]
commands:
  - name: junit
    run: rho-test-junit
    hook: run
rho test --list-plugins <project>   # what a run would answer to
rho test --no-plugins <project>     # a run with no extensions

modules/plugins/rho-test-junit is the worked example: it writes a JUnit report,
which is what a CI system reads. A plugin that fails is reported on standard
error and the run carries on, because one broken extension must not cost a
project its tests.

Reports

A plugin's report is written to a file and its notes are printed, because a
report is a document a system reads and a note is a line a person reads:

rho test <project> --report-dir build/test-reports

The default is build/test-reports beside the project, which is where a build
already keeps what a run produced.