Skip to content

Commit

Permalink
pkgs-lib/tests/formats: improve message on failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vcunat committed Oct 19, 2020
1 parent 298659b commit a76152a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkgs/pkgs-lib/tests/formats.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down

3 comments on commit a76152a

@vcunat
Copy link
Member Author

@vcunat vcunat commented on a76152a Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least lemme mention @infinisil and the original PR #75584, I guess.

@vcunat
Copy link
Member Author

@vcunat vcunat commented on a76152a Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, comparing serializations like this seems rather fragile, but practically the tests hopefully won't break often like 92c96b7.

@infinisil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the given serialization for the tests should be read and written again with a formatter

Please sign in to comment.