From 613d533c48b5cf436a7d549bc1d558d3f7e315fb Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 25 May 2016 15:34:38 -0400 Subject: [PATCH] nitunit manual: document NIT_TESTING, SRAND and NIT_TESTING_ID Signed-off-by: Jean Privat --- share/man/nitunit.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/share/man/nitunit.md b/share/man/nitunit.md index 0576201..e80e80e 100644 --- a/share/man/nitunit.md +++ b/share/man/nitunit.md @@ -312,6 +312,29 @@ Only display the skeleton, do not write any file. Indicate the specific Nit compiler executable to use. See `--nitc`. +### `NIT_TESTING` + +The environment variable `NIT_TESTING` is set to `true` during the execution of program tests. +Some libraries of programs can use it to produce specific reproducible results; or just to exit their executions. + +Unit-tests may unset this environment variable to retrieve the original behavior of such piece of software. + +### `SRAND` + +In order to maximize reproducibility, `SRAND` is set to 0. +This make the pseudo-random generator no random at all. +See `Sys::srand` for details. + +To retrieve the randomness, unit-tests may unset this environment variable then call `srand`. + +### `NIT_TESTING_ID` + +Parallel executions can cause some race collisions on named resources (e.g. DB table names). +To solve this issue, `NIT_TESTING_ID` is initialized with a distinct integer identifier that can be used to give unique names to resources. + +Note: `rand` is not a recommended way to get a distinct identifier because its randomness is disabled by default. See `SRAND`. + + # SEE ALSO The Nit language documentation and the source code of its tools and libraries may be downloaded from -- 1.7.9.5