add describe function

This commit is contained in:
tristan 2024-01-02 13:15:50 +00:00
parent 0b7f5ad721
commit 0dd646775e
7 changed files with 80 additions and 37 deletions

8
tix/describe.nix Normal file
View file

@ -0,0 +1,8 @@
name:
map ({
msg,
success,
actual ? null,
expected ? null,
} @ result:
result // {msg = "${name}: ${msg}";})

View file

@ -1,14 +1,14 @@
path: let
it = import ./it.nix;
describe = import ./describe.nix;
suite = import path;
in
builtins.trace ("testing " + builtins.baseNameOf path)
(
if !builtins.isFunction suite
then throw "A test suite should be in the form { it }: [ <tests> ]."
else
{
inherit path;
results = suite {inherit it;};
}
if !builtins.isFunction suite
then throw "A test suite should be in the form { it }: [ <tests> ]."
else {
inherit path;
results = suite {inherit it describe;};
}
)