diff --git a/lib/default.nix b/lib/default.nix index de48d55..dde07f6 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -209,41 +209,26 @@ rec { # with a nicer diff display function. check = { pkgs, tests }: let - system = pkgs.stdenv.targetPlatform.system; formatValue = val: if (builtins.isList val || builtins.isAttrs val) then builtins.toJSON val else builtins.toString val; + resultToString = { name, expected, result }: - pkgs.callPackage (pkgs.runCommand "nix-flake-tests-error" { + builtins.readFile (pkgs.runCommand "nix-flake-tests-error" { expected = formatValue expected; result = formatValue result; passAsFile = [ "expected" "result" ]; } '' - echo "${name} failed (- expected, + result)" + echo "${name} failed (- expected, + result)" > $out cp ''${expectedPath} ''${expectedPath}.json cp ''${resultPath} ''${resultPath}.json - ${pkgs.deepdiff}/bin/deep diff ''${expectedPath}.json ''${resultPath}.json - '') {}; + ${pkgs.deepdiff}/bin/deep diff ''${expectedPath}.json ''${resultPath}.json >> $out + ''); - - - # '' - # ${name} failed: expected ${formatValue expected}, but got ${ - # formatValue result - # } - # ''; results = pkgs.lib.runTests tests; in if results != [ ] then builtins.throw (builtins.concatStringsSep "\n" (map resultToString results)) - ## TODO: The derivation below is preferable but "nix flake check" hangs with it: - ## (it's preferable because "examples/many-failures" would then show all errors.) - # pkgs.runCommand "nix-flake-tests-failure" { } '' - # cat < $out";