From a0061153aca2bb13b167efd6263a6fa83150e160 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Tue, 9 Sep 2025 20:40:09 -0700 Subject: format test-case JSON before diffing it hopefully this will make the diffs more readable; otherwise the entire JSON file is a single huge line... depending on Perl feels heavyweight but keep in mind that Perl is already a mandatory part of any Linux system I'm familiar with, and it has a very nice JSON pretty-printer Change-Id: I817b4f6b63152673b31aeb32a3255d4c1b83942e --- checks.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'checks.nix') diff --git a/checks.nix b/checks.nix index c20451a..3e1b773 100644 --- a/checks.nix +++ b/checks.nix @@ -98,7 +98,7 @@ let sourceDerivations; }; - nativeBuildInputs = with pkgs; [ diffutils nix ]; + nativeBuildInputs = with pkgs; [ diffutils nix perl ]; # Recall that a nix flake check is a derivation; the check # succeeds if and only if the derivation builds successfully. @@ -113,10 +113,16 @@ let --extra-experimental-features nix-command \ --store /build/nix-store \ --show-trace \ - eval --json --file $src/input.nix > $out + eval --json --file $src/input.nix \ + | ${pkgs.perl}/bin/json_pp 2>/dev/null > $out + + cat $src/expected.json \ + | ${pkgs.perl}/bin/json_pp 2>/dev/null \ + > expected-pretty.json # The exit code of diff is what we want for this. Yay! - if ! ${pkgs.diffutils}/bin/diff $src/expected.json $out; then + if ! ${pkgs.diffutils}/bin/diff -u expected-pretty.json $out + then # It's good to keep the user-programmer in the loop... echo echo "This is a nix evaluation test case. The expected eval" -- cgit 1.4.1