Merge pull request #217818 from hsjobeki/doc/lib-runTests
Doc: better comments for lib.runTests
This commit is contained in:
commit
443707aac6
1 changed files with 56 additions and 8 deletions
|
@ -109,6 +109,8 @@ rec {
|
||||||
traceSeqN 2 { a.b.c = 3; } null
|
traceSeqN 2 { a.b.c = 3; } null
|
||||||
trace: { a = { b = {…}; }; }
|
trace: { a = { b = {…}; }; }
|
||||||
=> null
|
=> null
|
||||||
|
|
||||||
|
Type: traceSeqN :: Int -> a -> b -> b
|
||||||
*/
|
*/
|
||||||
traceSeqN = depth: x: y:
|
traceSeqN = depth: x: y:
|
||||||
let snip = v: if isList v then noQuotes "[…]" v
|
let snip = v: if isList v then noQuotes "[…]" v
|
||||||
|
@ -173,17 +175,63 @@ rec {
|
||||||
|
|
||||||
# -- TESTING --
|
# -- TESTING --
|
||||||
|
|
||||||
/* Evaluate a set of tests. A test is an attribute set `{expr,
|
/* Evaluates a set of tests.
|
||||||
expected}`, denoting an expression and its expected result. The
|
|
||||||
result is a list of failed tests, each represented as `{name,
|
A test is an attribute set `{expr, expected}`,
|
||||||
expected, actual}`, denoting the attribute name of the failing
|
denoting an expression and its expected result.
|
||||||
test and its expected and actual results.
|
|
||||||
|
The result is a `list` of __failed tests__, each represented as
|
||||||
|
`{name, expected, result}`,
|
||||||
|
|
||||||
|
- expected
|
||||||
|
- What was passed as `expected`
|
||||||
|
- result
|
||||||
|
- The actual `result` of the test
|
||||||
|
|
||||||
Used for regression testing of the functions in lib; see
|
Used for regression testing of the functions in lib; see
|
||||||
tests.nix for an example. Only tests having names starting with
|
tests.nix for more examples.
|
||||||
"test" are run.
|
|
||||||
|
|
||||||
Add attr { tests = ["testName"]; } to run these tests only.
|
Important: Only attributes that start with `test` are executed.
|
||||||
|
|
||||||
|
- If you want to run only a subset of the tests add the attribute `tests = ["testName"];`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
runTests {
|
||||||
|
testAndOk = {
|
||||||
|
expr = lib.and true false;
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
testAndFail = {
|
||||||
|
expr = lib.and true false;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
->
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name = "testAndFail";
|
||||||
|
expected = true;
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Type:
|
||||||
|
runTests :: {
|
||||||
|
tests = [ String ];
|
||||||
|
${testName} :: {
|
||||||
|
expr :: a;
|
||||||
|
expected :: a;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
->
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name :: String;
|
||||||
|
expected :: a;
|
||||||
|
result :: a;
|
||||||
|
}
|
||||||
|
]
|
||||||
*/
|
*/
|
||||||
runTests =
|
runTests =
|
||||||
# Tests to run
|
# Tests to run
|
||||||
|
|
Loading…
Reference in a new issue