2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-05 12:01:04 +00:00

Smarter fuzzy comparison for the “snapshot” integration test

This commit is contained in:
Romain 2017-11-24 21:56:45 +11:00
parent 19a28a08c0
commit bfdebe2c0f
9 changed files with 31 additions and 2 deletions

18
test-integration/imagediff Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env node
const gm = require('gm')
const TOLERANCE = { tolerance: 0.005 }
const expected = process.argv[2]
const actual = process.argv[3]
gm.compare(expected, actual, TOLERANCE, (err, similar) => {
if (err) {
console.error(`Error: ${err}\n Expected: ${expected}\n Actual: ${actual}`)
process.exit(1)
}
if (!similar) {
console.error(`Images are different\n Expected: ${expected}\n Actual: ${actual}`)
process.exit(2)
}
process.exit(0)
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -14,8 +14,19 @@ rm -rf output-actual
# run thumbsup
thumbsup --config config.json --output output-actual
# compare with expected output (checked-in)
diff -rub -x "metadata.json" -x "public" -x ".DS_Store" output-expected/ output-actual/
# compare albums with the snapshot
for expected in output-expected/*.html; do
actual=$(echo "${expected}" | sed s/expected/actual/)
diff -ub "${expected}" "${actual}"
done
# compare media with the snapshot
IFS=$'\n'; set -f
for expected in $(find output-expected/media -name "*.jpg"); do
actual=$(echo "${expected}" | sed s/expected/actual/)
./imagediff "${expected}" "${actual}"
done
unset IFS; set +f
echo "-------------------------------"
echo "Output is identical to snapshot"