blob: e2e8a1a2ae205489c4bd7d2ec6a7cdf1fa79e32b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/bash
cd $(dirname $0)/reference || exit
pdiff=$1
[ -n "$pdiff" ] || pdiff=../pdiff/perceptualdiff
if [ ! -e "${pdiff}" ]; then
echo "Error: requires pdiff executable"
exit 128
fi
exit_code=0
for file in *.ref.png; do
test=$(echo $file | cut -d'.' -f1)
target=$(echo $file | cut -d'.' -f2)
format=$(echo $file | cut -d'.' -f3)
notes=""
ref=""
result=""
if [ $target = 'base' ]; then
# Ignore the base images for this script's purposes
continue
elif [ $target = 'ref' ]; then
# This is actually the baseline reference image
continue
elif [ $format = 'ref' ]; then
# This is either a format-specific reference, or a target-specific/format-generic image
# In either case, compare it against the generic reference image
ref="$test.ref.png"
else
# Prefer the target-specific/format-generic reference image, if available
ref="$test.$target.ref.png"
if [ ! -e $ref ]; then
ref="$test.$format.ref.png"
fi
fi
# Special cases
if [ $test = "create-from-png" ]; then
# The create-from-png test utilizes multiple reference images directly
continue
elif [ $test = "fallback-resolution" ]; then
# The fallback-resolution test generates a set of reference images;
# These won't be redundant with one another, but just ignore them all.
continue
fi
if [ -e $ref ]; then
if cmp --silent "$ref" "$file" ; then
printf "redundant: %s and %s are byte-by-byte identical files\n" $file $ref
exit_code=1
else
# Run perceptualdiff with minimum threshold
pdiff_output=$($pdiff $ref $file -threshold 1)
result=${pdiff_output%:*}
notes=$(echo "${pdiff_output#*: }" | tail -n 1)
if [ "$result" = "PASS" ] && [ "$notes" = "Images are binary identical" ]; then
printf "redundant: %s and %s are pixel equivalent images\n" $file $ref
exit_code=1
notes=""
fi
fi
fi
done
exit $exit_code
|