Skip to content

Commit

Permalink
Improved compare-images script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 8, 2017
1 parent 20d2ce6 commit ddc3336
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
30 changes: 24 additions & 6 deletions test/compare-images
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,33 @@ for i in \
orthographic \
stereographic \
transverseMercator; do
test/render-world $i \
&& [ "$(compare -metric rmse img/$i.png test/output/$i.png null: 2>&1)" = "0 (0)" ] \
|| echo "✗ test/output/$i.png and img/$i.png differ"
test/render-world $i > test/output/$i.png \
&& [ "$(gm compare -metric rmse img/$i.png test/output/$i.png 2>&1)" = "Image Difference (RootMeanSquaredError):
Normalized Absolute
============ ==========
Red: 0.0000000000 0.0
Green: 0.0000000000 0.0
Blue: 0.0000000000 0.0
Total: 0.0000000000 0.0" ] \
&& echo -e "\x1B[1;32m✓ $2\x1B[0mtest/output/$i.png" \
&& rm -f -- test/output/$i-difference.png \
|| (gm compare -type TrueColor -highlight-style assign -highlight-color red -file test/output/$i-difference.png test/output/$i.png img/$i.png; \
echo -e "\x1B[1;31m✗ $2\x1B[0mtest/output/$i.png\n test/output/$i-difference.png")
done

for i in \
albers \
albersUsa; do
test/render-us $i \
&& [ "$(compare -metric rmse img/$i.png test/output/$i.png null: 2>&1)" = "0 (0)" ] \
|| echo "✗ test/output/$i.png and img/$i.png differ"
test/render-us $i > test/output/$i.png \
&& [ "$(gm compare -metric rmse img/$i.png test/output/$i.png 2>&1)" = "Image Difference (RootMeanSquaredError):
Normalized Absolute
============ ==========
Red: 0.0000000000 0.0
Green: 0.0000000000 0.0
Blue: 0.0000000000 0.0
Total: 0.0000000000 0.0" ] \
&& echo -e "\x1B[1;32m✓ $2\x1B[0mtest/output/$i.png" \
&& rm -f -- test/output/$i-difference.png \
|| (gm compare -type TrueColor -highlight-style assign -highlight-color red -file test/output/$i-difference.png test/output/$i.png img/$i.png; \
echo -e "\x1B[1;31m✗ $2\x1B[0mtest/output/$i.png\n test/output/$i-difference.png")
done
3 changes: 1 addition & 2 deletions test/render-us
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ context.lineWidth = 1;
context.strokeStyle = "#fff";
context.stroke();

console.warn("↳ test/output/" + projectionName + ".png");
canvas.pngStream().pipe(fs.createWriteStream("test/output/" + projectionName + ".png"));
canvas.pngStream().pipe(process.stdout);
3 changes: 1 addition & 2 deletions test/render-world
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ path(outline);
context.strokeStyle = "#000";
context.stroke();

console.warn("↳ test/output/" + projectionName + ".png");
canvas.pngStream().pipe(fs.createWriteStream("test/output/" + projectionName + ".png"));
canvas.pngStream().pipe(process.stdout);

0 comments on commit ddc3336

Please sign in to comment.