blob: 69f96c980f92ebde47d57d382c713e2eedcb84cc (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#!/bin/sh
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This tool compares the PDF output of Skia's DM tool of two commits.
CONTROL_COMMIT="$1"
EXPERIMENT_COMMIT="$2"
SOURCE="${3:-gm}" # could be 'skp'
if ! [ "$1" ] || ! [ "$2" ]; then
echo "usage:" >&2
echo " $0 CONTROL_COMMIT EXPERIMENT_COMMIT [SOURCE]" >&2
exit 1
fi
BAD=''
for CMD in 'python' 'ninja' 'pdfium_test' 'skdiff'; do
if ! command -v "$CMD" > /dev/null ; then
echo "could not find $CMD command in PATH." >&2
BAD=1
fi
done
if [ "$BAD" ]; then exit 1; fi
cd "$(dirname "$0")/.."
if [ "$(git diff --shortstat)" ]; then
echo "please stash your changes" >&2
exit 1
fi
DIR=$(mktemp -d "${TMPDIR:-/tmp}/skpdf.XXXXXXXXXX")
EXP="${DIR}/exp"
CON="${DIR}/con"
set -e
git checkout "$EXPERIMENT_COMMIT"
python bin/sync-and-gyp && ninja -C out/Release dm
out/Release/dm --src "$SOURCE" --config pdf -w "$EXP"
git checkout "$CONTROL_COMMIT"
python bin/sync-and-gyp && ninja -C out/Release dm
out/Release/dm --src "$SOURCE" --config pdf -w "$CON"
set +e
EXP_DIR="${EXP}/pdf/${SOURCE}"
CON_DIR="${CON}/pdf/${SOURCE}"
DIFFS=''
# remove byte-identical PDFs
for con in "$CON_DIR"/*pdf; do
exp="$EXP_DIR/$(basename "$con")"
if diff "$con" "$exp" > /dev/null; then
rm "$con" "$exp" # no difference
else
echo "PDF differs: $(basename "$con")"
DIFFS=1
fi
done
if [ -z "$DIFFS" ]; then
echo 'All PDFs are byte-identical!'
rm -r "$DIR"
exit 0;
fi
# Portable version of timeout from GNU coreutils.
timeout_py() { python -c "$(cat <<EOF
import sys, subprocess, threading
proc = subprocess.Popen(sys.argv[2:])
timer = threading.Timer(float(sys.argv[1]), proc.terminate)
timer.start()
proc.wait()
timer.cancel()
exit(proc.returncode)
EOF
)" "$@"; }
# rasterize the remaining PDFs
for pdf in "$CON_DIR"/*pdf "$EXP_DIR"/*pdf ; do
if timeout_py 10 pdfium_test --png "$pdf"; then
if ! [ -f "$pdf".*.png ] ; then
echo "Missing pdfium_test output: '$pdf.*.png'" >&2
exit 1
fi
rm "$pdf"
else
echo "pdfium_test '$pdf' failed."
fi
done
DIFFS=''
# remove byte-identical PNGs:
for con in "$CON_DIR"/*.png; do
exp="$EXP_DIR/$(basename "$con")"
if diff "$con" "$exp"; then
rm "$exp" "$con"
else
echo "PNG differs: $(basename "$con")"
DIFFS=1
fi
done
if [ -z "$DIFFS" ]; then
echo 'All PNGs are byte-identical!'
rm -r "$DIR"
exit 0;
fi
# run remaining PNG files through skdiff:
DIFF_DIR="${DIR}/skdiffout"
skdiff "$CON_DIR" "$EXP_DIR" "$DIFF_DIR"
echo "'$DIFF_DIR/index.html'"
if [ $(uname) = 'Darwin' ] ; then
open "$DIFF_DIR/index.html" # look at diffs
elif [ $(uname) = 'Linux' ] ; then
xdg-open "$DIFF_DIR/index.html" # look at diffs
fi
|