Skip to content

Commit

Permalink
Use emojis in test report
Browse files Browse the repository at this point in the history
  • Loading branch information
arnarg committed Aug 4, 2024
1 parent 1aaa2fb commit 3c249ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
38 changes: 23 additions & 15 deletions modules/testing/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,29 @@ in {
testing = {
success = lib.all (test: test.success) config.testing.tests;

report =
lib.concatMapStringsSep "\n" (
test: let
result =
if test.success
then "\\033[1;32mPASS\\033[0m"
else "\\033[1;31mFAIL\\033[0m";
in
"[${result}] ${test.name}"
+ (
lib.optionalString (!test.success)
"\n${test.report}"
)
)
config.testing.tests;
report = let
total = lib.length config.testing.tests;
passing = lib.length (lib.filter (test: test.success) config.testing.tests);
in
(lib.concatMapStringsSep "\n" (
test: let
result =
if test.success
then "✅"
else "❌";
in
"${result} ${test.name}"
+ (
lib.optionalString (!test.success)
"\n${test.report}"
)
)
config.testing.tests)
+ "\n\n${
if config.testing.success
then "🎉"
else "💥"
} ${toString passing}/${toString total} successful";

reportScript = pkgs.writeShellScript "testing-${config.testing.name}-report-script" ''
set -eo pipefail
Expand Down
2 changes: 1 addition & 1 deletion modules/testing/eval.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ in {
if success
then "\\033[1;32m✓\\033[0m"
else "\\033[1;31mx\\033[0m";
in " ${result} ${el.description}"
in " ${result} ${el.description}"
)
evaled.config.test.assertions;
};
Expand Down

0 comments on commit 3c249ea

Please sign in to comment.