summary refs log tree commit diff
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2020-10-19 21:39:13 +0200
committerVladimír Čunát <v@cunat.cz>2020-10-19 21:46:08 +0200
commita76152ac6eda0a9a918039401a81fc3e7ff8ee88 (patch)
treedfbd91dd89303898bd5821a30fe148caca487330
parent298659b5f8a8e266260ecb576fe47ad2bb8e63da (diff)
downloadnixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar.gz
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar.bz2
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar.lz
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar.xz
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.tar.zst
nixpkgs-a76152ac6eda0a9a918039401a81fc3e7ff8ee88.zip
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.
-rw-r--r--pkgs/pkgs-lib/tests/formats.nix8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkgs/pkgs-lib/tests/formats.nix b/pkgs/pkgs-lib/tests/formats.nix
index 3e52f74989d..16b760a5ada 100644
--- a/pkgs/pkgs-lib/tests/formats.nix
+++ b/pkgs/pkgs-lib/tests/formats.nix
@@ -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
   '';