rework describe function

This commit is contained in:
tristan 2024-01-03 10:14:28 +00:00
parent f125ec4c31
commit 2df95bbc56
7 changed files with 77 additions and 52 deletions

View file

@ -22,11 +22,16 @@
./mytest.nix
];
packages.x86_64-linux.watch = tix.watch {
packages.x86_64-linux.watchpipe = tix.watch {
cmd = "nix run --show-trace .#test file";
view = "tee -a /tmp/tix-output";
};
packages.x86_64-linux.watch = tix.watch {
cmd = "nix run --show-trace .#test";
view = "cat";
};
packages.x86_64-linux.results = pkgs.writeShellScriptBin "results" ''
tail -f -n1 /tmp/tix-output | {
while read out

View file

@ -2,15 +2,18 @@
describe,
it,
...
}:
describe "the describe function" [
}: [
(describe "the describe function" [
(it "returns an array with the message changed" {
expected = [
expected = {
component = "the describe function";
results = [
{
success = true;
msg = "the describe function: works";
msg = "works";
}
];
};
actual = describe "the describe function" [
{
success = true;
@ -18,4 +21,5 @@ describe "the describe function" [
}
];
})
])
]

View file

@ -2,8 +2,8 @@
it,
describe,
...
}:
describe "it" [
}: [
(describe "it" [
(it "test's itself???" rec {
expected = {
success = true;
@ -14,4 +14,5 @@ describe "it" [
actual = expected;
};
})
])
]

View file

@ -4,15 +4,20 @@
...
}: let
test = import ../tix/test.nix;
in
describe "the test function" [
in [
(describe "the test function" [
(it "get's test results" {
expected = [
{
"msg" = "it: test's itself???";
"component" = "it";
results = [
{
"msg" = "test's itself???";
"success" = true;
}
];
}
];
actual = (test ./it.test.nix).results;
})
(it "has a path" {
@ -23,4 +28,5 @@ in
actual = test ./bad/string.nix;
throws = true;
})
]
])
]

View file

@ -1,9 +1,13 @@
name:
name: tests:
builtins.trace "tix: ${name}"
map ({
{
component = name;
results = map ({
msg,
success,
actual ? null,
expected ? null,
} @ result:
result // {msg = "${name}: ${msg}";})
result)
tests;
}

View file

@ -3,10 +3,15 @@ let
in {
overview = ''
.[] | {
(.path): {
"${emotes.fail}": [.results | map(select(.success==false))[] | {(.msg): {actual, expected}}],
(.path):
.results[] | {
(.component): {
"${emotes.fail}": [
.results | map(select(.success==false))[] | {(.msg): {actual, expected}}
],
"${emotes.pass}": .results | map(select(.success) | .msg) | length
}
}
}
'';
}