Skip to content
Adam
Tools

The test suite

adamtest: test rows that are ordinary Adam programs.

adamtest

adamtest is Adam's test runner: it collects the tests, runs each through adam, compares what comes out with what the test expects and reports. For the test blocks a module carries itself, see Testing.

A test row

A test is an ordinary .adam file under a tests root with a spec block, @@test to @@end inside a block comment, each first on its line; its id is its folder and stem joined by a dot (flow.flow_breakpoint).

testsuite_row.adam
module exe testsuite_row;

/*
@@test
  kind run
  targets x86_64-windows-gnu x86_64-linux-gnu
  | 2 + 3 = 5
  | all sums checked
  | [Heap] Allocs: 0, Frees: 0, Leaked: 0
@@end
*/

// AFirst plus ASecond
func Add(const AFirst: int64; const ASecond: int64): int64;
begin
  return AFirst + ASecond;
end;

begin
  println("2 + 3 = {}", Add(2, 3));
  println("all sums checked");
end.
output on x86_64-windows-gnu and x86_64-linux-gnu
2 + 3 = 5
all sums checked

The spec

A spec's kind says what runs: check (adam check reports no error), error (the report markers say which reports come), cli (adam run with args, its output and exit code compared), run (built, then the exe run and compared), dep (built only for another test) or manual (a file a person checks in the editor). | text lines are the expected output, exitcode N the exit code, args the arguments, targets the triples a test is built and run for and levels the optimization levels, each in its own cell (none: one debug build, whose heap report is compared as any other line); <NUM> in an expected line matches any number.

A report marker is a line comment on the line the report is at, // ERROR SM0001: text (HINT, WARN, ERROR or FATAL, a code, an optional @column); an unmarked report fails the test, and so does a marker nothing reported (Diagnostics).

Running tests

adamtest <ids or globs> runs those tests, -all every one, -failed the ones the last run failed, -list [glob] lists them; -root <dir> takes the tests from another folder, -t <triple> only that target's, -adam <exe> tests another compiler. -bless rewrites a named test's expected lines from what it printed, each change noted under its PASS for review; -stop asks a running adamtest to stop before its next test, keeping the failed and unrun ones for -failed. A target this host cannot run is built and not run, said under the test's PASS, never a fail; an x86_64-linux-gnu program runs through WSL on Windows (Targets).

↑ ↓ moveEnter openEsc close