mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 09:54:20 +02:00
27 lines
876 B
Nix
27 lines
876 B
Nix
pkgs: tests: let
|
|
formatValue = val:
|
|
if (builtins.isList val || builtins.isAttrs val)
|
|
then builtins.toJSON val
|
|
else builtins.toString val;
|
|
resultToString = {
|
|
name,
|
|
expected,
|
|
result,
|
|
}: ''
|
|
${name} failed: expected ${formatValue expected}, but got ${
|
|
formatValue result
|
|
}
|
|
'';
|
|
results = pkgs.lib.runTests (tests pkgs);
|
|
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 <<EOF
|
|
# ${builtins.concatStringsSep "\n" (map resultToString results)}
|
|
# EOF
|
|
# exit 1
|
|
# ''
|
|
else pkgs.runCommand "nix-flake-tests-success" {} "echo > $out"
|