From 3c249ea62c837f8e745db2b68f69285eea37fcb3 Mon Sep 17 00:00:00 2001 From: Arnar Gauti Ingason Date: Sun, 4 Aug 2024 11:47:54 +0200 Subject: [PATCH] Use emojis in test report --- modules/testing/default.nix | 38 ++++++++++++++++++++++--------------- modules/testing/eval.nix | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/testing/default.nix b/modules/testing/default.nix index 9cf620b..b982b04 100644 --- a/modules/testing/default.nix +++ b/modules/testing/default.nix @@ -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 diff --git a/modules/testing/eval.nix b/modules/testing/eval.nix index 723e4d4..1a97522 100644 --- a/modules/testing/eval.nix +++ b/modules/testing/eval.nix @@ -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; };