diff options
| author | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-09-09 20:40:09 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-09-09 20:40:09 -0700 |
| commit | a0061153aca2bb13b167efd6263a6fa83150e160 (patch) | |
| tree | 67cce55008fa536332b98996da9bf75dd04d40ad /checks.nix | |
| parent | b7887228c4866b16b3d5cf7d923739ed9d7ea104 (diff) | |
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
Diffstat (limited to 'checks.nix')
| -rw-r--r-- | checks.nix | 12 |
1 files changed, 9 insertions, 3 deletions
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" |