pkgs-lib/tests/formats: improve message on failure

Foremost, the message was discarding double quotes on one side of the
diff, which was super-confusing to me, as I thought that the format
convertor broke that when in fact only whitespace was changed.

I thought I'd cat the files, but then... switching to `diff -u` seemed
self-sufficient.  It felt sufficiently non-controversial to push
directly, but certainly feel free to improve further.
This commit is contained in:
Vladimír Čunát 2020-10-19 21:39:13 +02:00
parent 298659b5f8
commit a76152ac6e
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA

View File

@ -15,11 +15,11 @@ let
in formatSet.generate "test-format-file" config;
runBuildTest = name: { drv, expected }: pkgs.runCommandNoCC name {} ''
if diff ${drv} ${builtins.toFile "expected" expected}; then
touch $out
if diff -u '${builtins.toFile "expected" expected}' '${drv}'; then
touch "$out"
else
echo "Got: $(cat ${drv})"
echo "Should be: ${expected}"
echo
echo "Got different values than expected; diff above."
exit 1
fi
'';