pretty printing

This commit is contained in:
Tristan 2024-01-03 07:18:33 +00:00
parent bee204701e
commit 6f72a66019
5 changed files with 22 additions and 14 deletions

View file

@ -1,5 +1,5 @@
name:
builtins.trace "testing ${name}"
builtins.trace "tix: ${name}"
map ({
msg,
success,

4
tix/emotes.nix Normal file
View file

@ -0,0 +1,4 @@
{
pass = "";
fail = "";
}

View file

@ -1,9 +1,11 @@
{
let
emotes = import ./emotes.nix;
in {
overview = ''
.[] | {
(.path): {
"": [.results | map(select(.success==false))[] | {(.msg): {actual, expected}}],
"": .results | map(select(.success) | .msg) | length
"${emotes.fail}": [.results | map(select(.success==false))[] | {(.msg): {actual, expected}}],
"${emotes.pass}": .results | map(select(.success) | .msg) | length
}
}
'';

View file

@ -7,6 +7,8 @@ msg: {
safeToPrint ? true,
throws ? false,
}: let
emotes = import ./emotes.nix;
preProcess = v:
if removeDunders
then undunder v
@ -24,19 +26,19 @@ msg: {
then builtins.removeAttrs v ["__toString" "__functor"]
else v;
success =
builtins.trace "testing if it ${msg}"
(
if throws
then (builtins.tryEval actual).success == false
else (a == e)
);
success = (
if throws
then (builtins.tryEval actual).success == false
else (a == e)
);
in
{
inherit success msg;
}
// (
if success
then {}
else builtins.trace "FAILED ${msg}" {inherit actual expected;}
then builtins.trace "tix: ${emotes.pass} ${msg}" {}
else
builtins.trace "tix: ${emotes.fail} ${msg}"
{inherit actual expected;}
)

View file

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