From 90684776508b6f7270892b83959ccfc84fa86649 Mon Sep 17 00:00:00 2001 From: technofab Date: Sun, 11 May 2025 02:05:01 +0200 Subject: [PATCH] fix: pretty print expected aswell when format is "pretty" --- flake.nix | 7 +++++++ lib/default.nix | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ee51b97..c22746d 100644 --- a/flake.nix +++ b/flake.nix @@ -99,6 +99,13 @@ }; }; } + { + name = "pretty-unit"; + format = "pretty"; + pos = __curPos; + expected = pkgs.hello; + actual = pkgs.hello; + } { name = "test-drv"; pos = __curPos; diff --git a/lib/default.nix b/lib/default.nix index 79fec2b..458fdc8 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -19,9 +19,14 @@ if format == "json" then actual else lib.generators.toPretty {} actual; + expected' = + if format == "json" + then expected + else lib.generators.toPretty {} expected; in { - inherit type name description expected; + inherit type name description; actual = actual'; + expected = expected'; # discard string context, otherwise it's being built instantly which we don't want actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or ""); pos =