git » firstones » commit 30a7e8f

test: Fix how we print failures for files with spaces

author Alberto Bertogli
2025-06-15 17:16:53 UTC
committer Alberto Bertogli
2025-06-15 17:19:42 UTC
parent c13cefac153671fa23b52a696c18a5b5f86e9cd7

test: Fix how we print failures for files with spaces

When a golden file has space in the name, and it fails the test, today
there is a bug when we print the friendly failure information: the logic
doesn't handle spaces well.

This patch fixes the problem by adjusting the iteration over the files.

test/run.sh +8 -4

diff --git a/test/run.sh b/test/run.sh
index f02ae6d..bd40e64 100755
--- a/test/run.sh
+++ b/test/run.sh
@@ -50,12 +50,16 @@ if ! ls --zero golden/*.png golden/auto/*.png | parallel -0 --results .3-compare
 	magick compare -metric SSIM -compose src \
 		{} .2-render/{/.}.png  .2-render/{/.}-diff.png ;
 then
-	for i in $(grep --files-with-matches -v '^1$' .3-compare/*.err); do
+	for i in .3-compare/*.err; do
+		if grep -q '^1$' "$i"; then
+			# The compare command prints "1" on equal files.
+			continue
+		fi
 		C="$(basename "$i" .err)"
 		echo "$C differs!"
-		echo "   view:   test/.2-render/$C.png"
-		echo "   diff:   test/.2-render/$C-diff.png"
-		echo "   accept: cp test/.2-render/$C.png test/golden/auto/"
+		echo "   view:   'test/.2-render/$C.png'"
+		echo "   diff:   'test/.2-render/$C-diff.png'"
+		echo "   accept: cp 'test/.2-render/$C.png' test/golden/auto/"
 		echo
 	done
 	fail