pretty printing
This commit is contained in:
parent
bee204701e
commit
6f72a66019
|
@ -1,5 +1,5 @@
|
||||||
name:
|
name:
|
||||||
builtins.trace "testing ${name}"
|
builtins.trace "tix: ├── ${name}"
|
||||||
map ({
|
map ({
|
||||||
msg,
|
msg,
|
||||||
success,
|
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 = ''
|
overview = ''
|
||||||
.[] | {
|
.[] | {
|
||||||
(.path): {
|
(.path): {
|
||||||
"❌": [.results | map(select(.success==false))[] | {(.msg): {actual, expected}}],
|
"${emotes.fail}": [.results | map(select(.success==false))[] | {(.msg): {actual, expected}}],
|
||||||
"✔️": .results | map(select(.success) | .msg) | length
|
"${emotes.pass}": .results | map(select(.success) | .msg) | length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
12
tix/it.nix
12
tix/it.nix
|
@ -7,6 +7,8 @@ msg: {
|
||||||
safeToPrint ? true,
|
safeToPrint ? true,
|
||||||
throws ? false,
|
throws ? false,
|
||||||
}: let
|
}: let
|
||||||
|
emotes = import ./emotes.nix;
|
||||||
|
|
||||||
preProcess = v:
|
preProcess = v:
|
||||||
if removeDunders
|
if removeDunders
|
||||||
then undunder v
|
then undunder v
|
||||||
|
@ -24,9 +26,7 @@ msg: {
|
||||||
then builtins.removeAttrs v ["__toString" "__functor"]
|
then builtins.removeAttrs v ["__toString" "__functor"]
|
||||||
else v;
|
else v;
|
||||||
|
|
||||||
success =
|
success = (
|
||||||
builtins.trace "testing if it ${msg}"
|
|
||||||
(
|
|
||||||
if throws
|
if throws
|
||||||
then (builtins.tryEval actual).success == false
|
then (builtins.tryEval actual).success == false
|
||||||
else (a == e)
|
else (a == e)
|
||||||
|
@ -37,6 +37,8 @@ in
|
||||||
}
|
}
|
||||||
// (
|
// (
|
||||||
if success
|
if success
|
||||||
then {}
|
then builtins.trace "tix: │ ├── ${emotes.pass} ${msg}" {}
|
||||||
else builtins.trace "FAILED ${msg}" {inherit actual expected;}
|
else
|
||||||
|
builtins.trace "tix: │ ├── ${emotes.fail} ${msg}"
|
||||||
|
{inherit actual expected;}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ path: let
|
||||||
describe = import ./describe.nix;
|
describe = import ./describe.nix;
|
||||||
suite = import path;
|
suite = import path;
|
||||||
in
|
in
|
||||||
builtins.trace ("testing " + builtins.baseNameOf path)
|
builtins.trace ("tix: " + builtins.baseNameOf path)
|
||||||
(
|
(
|
||||||
if !builtins.isFunction suite
|
if !builtins.isFunction suite
|
||||||
then throw "A test suite should be in the form { it }: [ <tests> ]."
|
then throw "A test suite should be in the form { it }: [ <tests> ]."
|
||||||
|
|
Loading…
Reference in a new issue