pretty printing
This commit is contained in:
parent
bee204701e
commit
6f72a66019
|
@ -1,5 +1,5 @@
|
|||
name:
|
||||
builtins.trace "testing ${name}"
|
||||
builtins.trace "tix: ├── ${name}"
|
||||
map ({
|
||||
msg,
|
||||
success,
|
||||
|
|
4
tix/emotes.nix
Normal file
4
tix/emotes.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
pass = "✔️";
|
||||
fail = "❌";
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
|
20
tix/it.nix
20
tix/it.nix
|
@ -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;}
|
||||
)
|
||||
|
|
|
@ -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> ]."
|
||||
|
|
Loading…
Reference in a new issue