Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: tools/pdf-comparison.sh

Issue 1921943006: tools/pdf-comparison.sh: stop relying on /usr/bin/timeout (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 2
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 # This tool compares the PDF output of Skia's DM tool of two commits. 8 # This tool compares the PDF output of Skia's DM tool of two commits.
9 9
10 CONTROL_COMMIT="$1" 10 CONTROL_COMMIT="$1"
11 EXPERIMENT_COMMIT="$2" 11 EXPERIMENT_COMMIT="$2"
12 12
13 SOURCE="${3:-gm}" # could be 'skp' 13 SOURCE="${3:-gm}" # could be 'skp'
14 14
15 if ! [ "$1" ] || ! [ "$2" ]; then 15 if ! [ "$1" ] || ! [ "$2" ]; then
16 echo "usage:" >&2 16 echo "usage:" >&2
17 echo " $0 CONTROL_COMMIT EXPERIMENT_COMMIT [SOURCE]" >&2 17 echo " $0 CONTROL_COMMIT EXPERIMENT_COMMIT [SOURCE]" >&2
18 exit 1 18 exit 1
19 fi 19 fi
20 20
21 BAD='' 21 BAD=''
22 for CMD in 'python' 'ninja' 'pdfium_test' 'timeout' 'skdiff'; do 22 for CMD in 'python' 'ninja' 'pdfium_test' 'skdiff'; do
23 if ! command -v "$CMD" > /dev/null ; then 23 if ! command -v "$CMD" > /dev/null ; then
24 echo "could not find $CMD command in PATH." >&2 24 echo "could not find $CMD command in PATH." >&2
25 BAD=1 25 BAD=1
26 fi 26 fi
27 done 27 done
28 if [ "$BAD" ]; then exit 1; fi 28 if [ "$BAD" ]; then exit 1; fi
29 29
30 cd "$(dirname "$0")/.." 30 cd "$(dirname "$0")/.."
31 if [ "$(git diff --shortstat)" ]; then 31 if [ "$(git diff --shortstat)" ]; then
32 echo "please stash your changes" >&2 32 echo "please stash your changes" >&2
(...skipping 29 matching lines...) Expand all
62 echo "PDF differs: $(basename "$con")" 62 echo "PDF differs: $(basename "$con")"
63 DIFFS=1 63 DIFFS=1
64 fi 64 fi
65 done 65 done
66 if [ -z "$DIFFS" ]; then 66 if [ -z "$DIFFS" ]; then
67 echo 'All PDFs are byte-identical!' 67 echo 'All PDFs are byte-identical!'
68 rm -r "$DIR" 68 rm -r "$DIR"
69 exit 0; 69 exit 0;
70 fi 70 fi
71 71
72 # Portable version of timeout from GNU coreutils.
73 timeout_py() { python -c "$(cat <<EOF
74 import sys, subprocess, threading
75 proc = subprocess.Popen(sys.argv[2:])
76 timer = threading.Timer(float(sys.argv[1]), proc.terminate)
77 timer.start()
78 proc.wait()
79 timer.cancel()
80 exit(proc.returncode)
81 EOF
82 )" "$@"; }
83
72 # rasterize the remaining PDFs 84 # rasterize the remaining PDFs
73 for pdf in "$CON_DIR"/*pdf "$EXP_DIR"/*pdf ; do 85 for pdf in "$CON_DIR"/*pdf "$EXP_DIR"/*pdf ; do
74 # timeout is from GNU coreutils 86 if timeout_py 10 pdfium_test --png "$pdf"; then
75 if timeout 10 pdfium_test --png "$pdf"; then 87 if ! [ -f "$pdf".*.png ] ; then
88 echo "Missing pdfium_test output: '$pdf.*.png'" >&2
89 exit 1
90 fi
76 rm "$pdf" 91 rm "$pdf"
77 else 92 else
78 echo "pdfium_test '$pdf' failed." 93 echo "pdfium_test '$pdf' failed."
79 fi 94 fi
80 done 95 done
81 96
82 DIFFS='' 97 DIFFS=''
83 # remove byte-identical PNGs: 98 # remove byte-identical PNGs:
84 for con in "$CON_DIR"/*.png; do 99 for con in "$CON_DIR"/*.png; do
85 exp="$EXP_DIR/$(basename "$con")" 100 exp="$EXP_DIR/$(basename "$con")"
(...skipping 13 matching lines...) Expand all
99 # run remaining PNG files through skdiff: 114 # run remaining PNG files through skdiff:
100 DIFF_DIR="${DIR}/skdiffout" 115 DIFF_DIR="${DIR}/skdiffout"
101 skdiff "$CON_DIR" "$EXP_DIR" "$DIFF_DIR" 116 skdiff "$CON_DIR" "$EXP_DIR" "$DIFF_DIR"
102 echo "'$DIFF_DIR/index.html'" 117 echo "'$DIFF_DIR/index.html'"
103 118
104 if [ $(uname) = 'Darwin' ] ; then 119 if [ $(uname) = 'Darwin' ] ; then
105 open "$DIFF_DIR/index.html" # look at diffs 120 open "$DIFF_DIR/index.html" # look at diffs
106 elif [ $(uname) = 'Linux' ] ; then 121 elif [ $(uname) = 'Linux' ] ; then
107 xdg-open "$DIFF_DIR/index.html" # look at diffs 122 xdg-open "$DIFF_DIR/index.html" # look at diffs
108 fi 123 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698