summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-02-23 12:01:07 +0000
committerGitHub <noreply@github.com>2023-02-23 12:01:07 +0000
commit390b789c3950307a9dc6bb57d2f5f0ae69cfc76b (patch)
treecdf28320248b5ecfea4cbe8a3719ed68db7a7759 /lib
parent010946fcbd99c7dd20417ad387cf395c0d59d1b9 (diff)
parent984655a3c7c125eaf2fbc46d4f32bfe17f67e0e7 (diff)
Merge master into staging-next
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.nix66
1 files changed, 57 insertions, 9 deletions
diff --git a/lib/debug.nix b/lib/debug.nix
index e3ca3352397e..35ca4c7dfb20 100644
--- a/lib/debug.nix
+++ b/lib/debug.nix
@@ -109,6 +109,8 @@ rec {
traceSeqN 2 { a.b.c = 3; } null
trace: { a = { b = {…}; }; }
=> null
+
+ Type: traceSeqN :: Int -> a -> b -> b
*/
traceSeqN = depth: x: y:
let snip = v: if isList v then noQuotes "[…]" v
@@ -173,17 +175,63 @@ rec {
# -- TESTING --
- /* Evaluate a set of tests. A test is an attribute set `{expr,
- expected}`, denoting an expression and its expected result. The
- result is a list of failed tests, each represented as `{name,
- expected, actual}`, denoting the attribute name of the failing
- test and its expected and actual results.
+ /* Evaluates a set of tests.
- Used for regression testing of the functions in lib; see
- tests.nix for an example. Only tests having names starting with
- "test" are run.
+ A test is an attribute set `{expr, expected}`,
+ denoting an expression and its expected result.
+
+ 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
- Add attr { tests = ["testName"]; } to run these tests only.
+ Used for regression testing of the functions in lib; see
+ tests.nix for more examples.
+
+ 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 =
# Tests to run