Smarter fuzzy comparison for the “snapshot” integration test
18
test-integration/imagediff
Executable 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)
|
||||
})
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.4 KiB |
@ -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"
|
||||
|