.\" raztest(1) - build and run the tests of a raz program .Dd October 22, 2026 .Dt RAZTEST 1 .Os .Sh NAME .Nm raztest .Nd build and run the tests of a raz program .Sh SYNOPSIS .Nm .Op Fl I Ar dir .Op Fl j Ar n .Op Fl t Ar secs .Op Fl o Ar dir .Op Fl r Ar text .Op Fl w .Op Fl \-tap .Op Fl \-junit Ar file .Op Fl \-seed Ar n .Op Fl \-fuzz Ar secs .Ar file.raz Ns | Ns Ar dir ... .Sh DESCRIPTION .Nm builds each test with .Ic raz -Werror , runs it, and says which passed. A test is a module whose .Ic main is its test: it passes if it builds and then exits with status 0, as a program that checks with the library's .Ic Check does when no check fails. .Pp The tests are the files given. A directory gives each .Pa *.raz directly in it that has a line starting .Ql proc main* , in the order of their names. A test's name is its file's, without .Pa .raz ; two tests may not share one. .Pp Each test is built into the .Fl o directory as .Ar name , and run there with standard input from .Pa /dev/null , in a process group of its own. What the compiler writes, and then what the test writes on standard output and standard error, goes to .Ar name Ns .out beside it, which stays for a look afterwards. A build or a run that takes longer than the .Fl t seconds has its process group killed. .Pp As each test ends, .Nm writes a line for it, in the order the tests were given: the word .Ql ok , .Ql FAIL or .Ql TIMEOUT , the file, for a failure what failed, such as .Ql doesn't compile , .Ql status 1 or .Ql signal 11 , and the seconds it took to build and run. Under a failure comes its .Pa .out , indented by four spaces. Last comes a summary: .Bd -literal -offset indent 12 passed, 1 failed, 0 timed out, 3.41s .Ed .Pp The three words are in colour when standard output is a terminal. .Pp With .Fl \-tap standard output is TAP version 14 instead: the lines .Ql TAP version 14 and .Ql 1..N , then for each test .Ql ok K - file or .Ql not ok K - file # status 1 (the same reason as the .Ql FAIL line, or .Ql timed out ) , with a failure's .Pa .out under it as comment lines starting with .Ql # , and the summary as a last comment line. There is no colour. .Sh OPTIONS .Bl -tag -width "--junit file" .It Fl I Ar dir Look for modules in .Ar dir too, as .Ic raz -I does. It may be given more than once. .It Fl j Ar n Build and run .Ar n tests at once; 1 if not given. .It Fl t Ar secs Kill a build, or a run, that takes longer than .Ar secs seconds; 60 if not given. .It Fl o Ar dir Put the programs and their .Pa .out files in .Ar dir , made if it isn't there; .Pa build/raztest if not given. .It Fl r Ar text Run only the tests whose name holds .Ar text . .It Fl w , Fl \-watch Run the tests, then run them all again whenever a file changes, until interrupted. Watched are the .Pa *.raz files directly in the directory of each test file given, in each directory given, and in each .Fl I directory, not those below them. The files' times and sizes are looked at every 300 ms, and a change is waited out until the files stay as they are for one look, since an editor writes in steps. All the tests run again, not only those a change reaches. The operands are read again each time, so a new test file is found. On a terminal the screen is cleared before each run, and .Ql watching N files; ^C stops is written after the summary. With .Fl \-junit the file is written again after each run. .It Fl \-tap Write TAP instead of the usual lines. .It Fl \-junit Ar file Besides the usual output, write the results to .Ar file as JUnit XML, which CI services read: one .Ql testcase for each test, its .Ql classname the file, with a .Ql failure holding the log for one that failed or timed out. The directory of .Ar file must exist; if it can't be written, the status is 2. Control bytes XML 1.0 forbids in a log are written as .Ql \&? ; invalid UTF-8 is passed through. .It Fl \-seed Ar n For tests that use the library's .Ic Prop : set .Ev PROP_SEED to .Ar n , a whole number from 0, so that their fresh cases are those of an earlier run, which a failing property names. .It Fl \-fuzz Ar secs For tests that use .Ic Prop : set .Ev PROP_TIME to .Ar secs , so that each property is tried on fresh cases for that many seconds, not on 100 of them. It raises .Fl t to .Ar secs + 60, unless .Fl t is given. That is enough for one property in a test; a test with several properties needs .Fl t to say more. .It Fl h , Fl \-help Say the options, and exit. .El .Sh ENVIRONMENT .Bl -tag -width "NO_COLOR" .It Ev RAZ The compiler; if unset, .Ic raz on the .Ev PATH . .It Ev NO_COLOR If set and not empty, no colour. .El .Sh EXIT STATUS 0 if every test passed; 1 if one failed or timed out; 2 for a mistake in the command line, a file that isn't there, or an output directory that can't be made. Stopped by an interrupt or a hangup, it kills the tests under way and exits with 128 and the signal's number. .Sh EXAMPLES Run a project's tests, four at a time: .Bd -literal -offset indent raztest -j 4 -I src test .Ed .Pp In CI, with a report for the service to show: .Bd -literal -offset indent raztest -j 4 -I src --junit build/junit.xml test .Ed .Pp Fuzz each property of the tests in .Pa test for ten minutes: .Bd -literal -offset indent raztest -I src --fuzz 600 test .Ed .Pp A Makefile's check that uses .Nm where it is installed, and its own loop where it isn't: .Bd -literal -offset indent check: @if command -v raztest >/dev/null; then raztest -I src test; \e else fail=0; for f in test/*.raz; do \e raz -Werror -I src -o build/t $$f && build/t || fail=1; \e done; test $$fail = 0; fi .Ed .Sh SEE ALSO .Xr raz 1 , .Xr raz-lib 3 .Sh BUGS .Fl j doesn't default to the number of processors, which the library can't tell yet.