| 1 | .\" raztest(1) - build and run the tests of a raz program |
| 2 | .Dd October 22, 2026 |
| 3 | .Dt RAZTEST 1 |
| 4 | .Os |
| 5 | .Sh NAME |
| 6 | .Nm raztest |
| 7 | .Nd build and run the tests of a raz program |
| 8 | .Sh SYNOPSIS |
| 9 | .Nm |
| 10 | .Op Fl I Ar dir |
| 11 | .Op Fl j Ar n |
| 12 | .Op Fl t Ar secs |
| 13 | .Op Fl o Ar dir |
| 14 | .Op Fl r Ar text |
| 15 | .Op Fl w |
| 16 | .Op Fl \-tap |
| 17 | .Op Fl \-junit Ar file |
| 18 | .Op Fl \-seed Ar n |
| 19 | .Op Fl \-fuzz Ar secs |
| 20 | .Ar file.raz Ns | Ns Ar dir ... |
| 21 | .Sh DESCRIPTION |
| 22 | .Nm |
| 23 | builds each test with |
| 24 | .Ic raz -Werror , |
| 25 | runs it, and says which passed. |
| 26 | A test is a module whose |
| 27 | .Ic main |
| 28 | is its test: it passes if it builds and then exits with status 0, as a |
| 29 | program that checks with the library's |
| 30 | .Ic Check |
| 31 | does when no check fails. |
| 32 | .Pp |
| 33 | The tests are the files given. |
| 34 | A directory gives each |
| 35 | .Pa *.raz |
| 36 | directly in it that has a line starting |
| 37 | .Ql proc main* , |
| 38 | in the order of their names. |
| 39 | A test's name is its file's, without |
| 40 | .Pa .raz ; |
| 41 | two tests may not share one. |
| 42 | .Pp |
| 43 | Each test is built into the |
| 44 | .Fl o |
| 45 | directory as |
| 46 | .Ar name , |
| 47 | and run there with standard input from |
| 48 | .Pa /dev/null , |
| 49 | in a process group of its own. |
| 50 | What the compiler writes, and then what the test writes on standard |
| 51 | output and standard error, goes to |
| 52 | .Ar name Ns .out |
| 53 | beside it, which stays for a look afterwards. |
| 54 | A build or a run that takes longer than the |
| 55 | .Fl t |
| 56 | seconds has its process group killed. |
| 57 | .Pp |
| 58 | As each test ends, |
| 59 | .Nm |
| 60 | writes a line for it, in the order the tests were given: the word |
| 61 | .Ql ok , |
| 62 | .Ql FAIL |
| 63 | or |
| 64 | .Ql TIMEOUT , |
| 65 | the file, for a failure what failed, |
| 66 | such as |
| 67 | .Ql doesn't compile , |
| 68 | .Ql status 1 |
| 69 | or |
| 70 | .Ql signal 11 , |
| 71 | and the seconds it took to build and run. |
| 72 | Under a failure comes its |
| 73 | .Pa .out , |
| 74 | indented by four spaces. |
| 75 | Last comes a summary: |
| 76 | .Bd -literal -offset indent |
| 77 | 12 passed, 1 failed, 0 timed out, 3.41s |
| 78 | .Ed |
| 79 | .Pp |
| 80 | The three words are in colour when standard output is a terminal. |
| 81 | .Pp |
| 82 | With |
| 83 | .Fl \-tap |
| 84 | standard output is TAP version 14 instead: the lines |
| 85 | .Ql TAP version 14 |
| 86 | and |
| 87 | .Ql 1..N , |
| 88 | then for each test |
| 89 | .Ql ok K - file |
| 90 | or |
| 91 | .Ql not ok K - file # status 1 |
| 92 | (the same reason as the |
| 93 | .Ql FAIL |
| 94 | line, or |
| 95 | .Ql timed out ) , |
| 96 | with a failure's |
| 97 | .Pa .out |
| 98 | under it as comment lines starting with |
| 99 | .Ql # , |
| 100 | and the summary as a last comment line. |
| 101 | There is no colour. |
| 102 | .Sh OPTIONS |
| 103 | .Bl -tag -width "--junit file" |
| 104 | .It Fl I Ar dir |
| 105 | Look for modules in |
| 106 | .Ar dir |
| 107 | too, as |
| 108 | .Ic raz -I |
| 109 | does. |
| 110 | It may be given more than once. |
| 111 | .It Fl j Ar n |
| 112 | Build and run |
| 113 | .Ar n |
| 114 | tests at once; 1 if not given. |
| 115 | .It Fl t Ar secs |
| 116 | Kill a build, or a run, that takes longer than |
| 117 | .Ar secs |
| 118 | seconds; 60 if not given. |
| 119 | .It Fl o Ar dir |
| 120 | Put the programs and their |
| 121 | .Pa .out |
| 122 | files in |
| 123 | .Ar dir , |
| 124 | made if it isn't there; |
| 125 | .Pa build/raztest |
| 126 | if not given. |
| 127 | .It Fl r Ar text |
| 128 | Run only the tests whose name holds |
| 129 | .Ar text . |
| 130 | .It Fl w , Fl \-watch |
| 131 | Run the tests, then run them all again whenever a file changes, until |
| 132 | interrupted. |
| 133 | Watched are the |
| 134 | .Pa *.raz |
| 135 | files directly in the directory of each test file given, in each |
| 136 | directory given, and in each |
| 137 | .Fl I |
| 138 | directory, not those below them. |
| 139 | The files' times and sizes are looked at every 300 ms, and a change is |
| 140 | waited out until the files stay as they are for one look, since an |
| 141 | editor writes in steps. |
| 142 | All the tests run again, not only those a change reaches. |
| 143 | The operands are read again each time, so a new test file is found. |
| 144 | On a terminal the screen is cleared before each run, and |
| 145 | .Ql watching N files; ^C stops |
| 146 | is written after the summary. |
| 147 | With |
| 148 | .Fl \-junit |
| 149 | the file is written again after each run. |
| 150 | .It Fl \-tap |
| 151 | Write TAP instead of the usual lines. |
| 152 | .It Fl \-junit Ar file |
| 153 | Besides the usual output, write the results to |
| 154 | .Ar file |
| 155 | as JUnit XML, which CI services read: one |
| 156 | .Ql testcase |
| 157 | for each test, its |
| 158 | .Ql classname |
| 159 | the file, with a |
| 160 | .Ql failure |
| 161 | holding the log for one that failed or timed out. |
| 162 | The directory of |
| 163 | .Ar file |
| 164 | must exist; if it can't be written, the status is 2. |
| 165 | Control bytes XML 1.0 forbids in a log are written as |
| 166 | .Ql \&? ; |
| 167 | invalid UTF-8 is passed through. |
| 168 | .It Fl \-seed Ar n |
| 169 | For tests that use the library's |
| 170 | .Ic Prop : |
| 171 | set |
| 172 | .Ev PROP_SEED |
| 173 | to |
| 174 | .Ar n , |
| 175 | a whole number from 0, so that their fresh cases are those of an |
| 176 | earlier run, which a failing property names. |
| 177 | .It Fl \-fuzz Ar secs |
| 178 | For tests that use |
| 179 | .Ic Prop : |
| 180 | set |
| 181 | .Ev PROP_TIME |
| 182 | to |
| 183 | .Ar secs , |
| 184 | so that each property is tried on fresh cases for that many seconds, |
| 185 | not on 100 of them. |
| 186 | It raises |
| 187 | .Fl t |
| 188 | to |
| 189 | .Ar secs |
| 190 | + 60, unless |
| 191 | .Fl t |
| 192 | is given. |
| 193 | That is enough for one property in a test; a test with several |
| 194 | properties needs |
| 195 | .Fl t |
| 196 | to say more. |
| 197 | .It Fl h , Fl \-help |
| 198 | Say the options, and exit. |
| 199 | .El |
| 200 | .Sh ENVIRONMENT |
| 201 | .Bl -tag -width "NO_COLOR" |
| 202 | .It Ev RAZ |
| 203 | The compiler; if unset, |
| 204 | .Ic raz |
| 205 | on the |
| 206 | .Ev PATH . |
| 207 | .It Ev NO_COLOR |
| 208 | If set and not empty, no colour. |
| 209 | .El |
| 210 | .Sh EXIT STATUS |
| 211 | 0 if every test passed; 1 if one failed or timed out; 2 for a mistake |
| 212 | in the command line, a file that isn't there, or an output directory |
| 213 | that can't be made. |
| 214 | Stopped by an interrupt or a hangup, it kills the tests under way and |
| 215 | exits with 128 and the signal's number. |
| 216 | .Sh EXAMPLES |
| 217 | Run a project's tests, four at a time: |
| 218 | .Bd -literal -offset indent |
| 219 | raztest -j 4 -I src test |
| 220 | .Ed |
| 221 | .Pp |
| 222 | In CI, with a report for the service to show: |
| 223 | .Bd -literal -offset indent |
| 224 | raztest -j 4 -I src --junit build/junit.xml test |
| 225 | .Ed |
| 226 | .Pp |
| 227 | Fuzz each property of the tests in |
| 228 | .Pa test |
| 229 | for ten minutes: |
| 230 | .Bd -literal -offset indent |
| 231 | raztest -I src --fuzz 600 test |
| 232 | .Ed |
| 233 | .Pp |
| 234 | A Makefile's check that uses |
| 235 | .Nm |
| 236 | where it is installed, and its own loop where it isn't: |
| 237 | .Bd -literal -offset indent |
| 238 | check: |
| 239 | @if command -v raztest >/dev/null; then raztest -I src test; \e |
| 240 | else fail=0; for f in test/*.raz; do \e |
| 241 | raz -Werror -I src -o build/t $$f && build/t || fail=1; \e |
| 242 | done; test $$fail = 0; fi |
| 243 | .Ed |
| 244 | .Sh SEE ALSO |
| 245 | .Xr raz 1 , |
| 246 | .Xr raz-lib 3 |
| 247 | .Sh BUGS |
| 248 | .Fl j |
| 249 | doesn't default to the number of processors, which the library can't |
| 250 | tell yet. |