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

Side by Side Diff: tools/tests/run.sh

Issue 18348015: rebaseline.py self-tests: prepare to add tests of JSON-format rebaselining (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Tests for our tools. 3 # Tests for our tools.
4 # 4 #
5 # TODO: currently, this only passes on Linux (which is the platform that 5 # TODO: currently, this only passes on Linux (which is the platform that
6 # the housekeeper bot runs on, e.g. 6 # the housekeeper bot runs on, e.g.
7 # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1415/st eps/RunToolSelfTests/logs/stdio ) 7 # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1415/st eps/RunToolSelfTests/logs/stdio )
8 # See https://code.google.com/p/skia/issues/detail?id=677 8 # See https://code.google.com/p/skia/issues/detail?id=677
9 # ('make tools/tests/run.sh work cross-platform') 9 # ('make tools/tests/run.sh work cross-platform')
10 # Ideally, these tests should pass on all development platforms... 10 # Ideally, these tests should pass on all development platforms...
(...skipping 21 matching lines...) Expand all
32 # Compare contents of all files within directories $1 and $2, 32 # Compare contents of all files within directories $1 and $2,
33 # EXCEPT for any dotfiles. 33 # EXCEPT for any dotfiles.
34 # If there are any differences, a description is written to stdout and 34 # If there are any differences, a description is written to stdout and
35 # we exit with a nonzero return value. 35 # we exit with a nonzero return value.
36 # Otherwise, we write nothing to stdout and return. 36 # Otherwise, we write nothing to stdout and return.
37 function compare_directories { 37 function compare_directories {
38 if [ $# != 2 ]; then 38 if [ $# != 2 ]; then
39 echo "compare_directories requires exactly 2 parameters, got $#" 39 echo "compare_directories requires exactly 2 parameters, got $#"
40 exit 1 40 exit 1
41 fi 41 fi
42 diff --exclude=.* $1 $2 42 diff --recursive --exclude=.* $1 $2
epoger 2013/07/03 17:00:07 Gotta do this so we compare the expected-results.j
43 if [ $? != 0 ]; then 43 if [ $? != 0 ]; then
44 echo "failed in: compare_directories $1 $2" 44 echo "failed in: compare_directories $1 $2"
45 exit 1 45 exit 1
46 fi 46 fi
47 } 47 }
48 48
49 # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff 49 # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff
50 # to write its output, if any, to directory $2/output-actual). 50 # to write its output, if any, to directory $2/output-actual).
51 # Then compare its results against those in $2/output-expected. 51 # Then compare its results against those in $2/output-expected.
52 function skdiff_test { 52 function skdiff_test {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout 122 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
123 echo $? >$ACTUAL_OUTPUT_DIR/return_value 123 echo $? >$ACTUAL_OUTPUT_DIR/return_value
124 END_TIMESTAMP=$(date +%s) 124 END_TIMESTAMP=$(date +%s)
125 125
126 SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) 126 SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP)
127 echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" 127 echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete"
128 128
129 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR 129 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
130 } 130 }
131 131
132 # Test rebaseline.py's soon-to-disappear image file rebaselining capability.
133 #
132 # Run rebaseline.py with arguments in $1, recording its dry-run output. 134 # Run rebaseline.py with arguments in $1, recording its dry-run output.
133 # Then compare that dry-run output to the content of $2/output-expected. 135 # Then compare that dry-run output to the content of $2/output-expected.
134 function rebaseline_test { 136 function rebaseline_images_test {
135 if [ $# != 2 ]; then 137 if [ $# != 2 ]; then
136 echo "rebaseline_test requires exactly 2 parameters, got $#" 138 echo "rebaseline_test requires exactly 2 parameters, got $#"
137 exit 1 139 exit 1
138 fi 140 fi
139 ARGS="$1" 141 ARGS="$1"
140 ACTUAL_OUTPUT_DIR="$2/output-actual" 142 ACTUAL_OUTPUT_DIR="$2/output-actual"
141 EXPECTED_OUTPUT_DIR="$2/output-expected" 143 EXPECTED_OUTPUT_DIR="$2/output-expected"
142 144
143 rm -rf $ACTUAL_OUTPUT_DIR 145 rm -rf $ACTUAL_OUTPUT_DIR
144 mkdir -p $ACTUAL_OUTPUT_DIR 146 mkdir -p $ACTUAL_OUTPUT_DIR
145 COMMAND="python tools/rebaseline.py --dry-run $ARGS" 147 COMMAND="python tools/rebaseline.py --dry-run $ARGS"
146 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line 148 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
147 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout 149 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
148 echo $? >$ACTUAL_OUTPUT_DIR/return_value 150 echo $? >$ACTUAL_OUTPUT_DIR/return_value
149 151
150 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR 152 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
151 } 153 }
152 154
155 # EPOGER
156 # Test rebaseline.py's new JSON-format expectations rebaselining capability.
157 #
158 # Copy expected-result.json files from $1 into a dir where they can be modified.
159 # Run rebaseline.py with arguments in $2, recording its output.
160 # Then compare the output (and modified expected-result.json files) to the
161 # content of $2/output-expected.
162 function rebaseline_test {
163 if [ $# != 3 ]; then
164 echo "rebaseline_test requires exactly 3 parameters, got $#"
165 exit 1
166 fi
167 COPY_EXPECTATIONS_FROM_DIR="$1"
168 ARGS="$2"
169 ACTUAL_OUTPUT_DIR="$3/output-actual"
170 EXPECTED_OUTPUT_DIR="$3/output-expected"
171
172 rm -rf $ACTUAL_OUTPUT_DIR
173 mkdir -p $ACTUAL_OUTPUT_DIR
174 EXPECTATIONS_TO_MODIFY_DIR="$ACTUAL_OUTPUT_DIR/gm-expectations"
175 SUBDIRS=$(ls $COPY_EXPECTATIONS_FROM_DIR)
176 for SUBDIR in $SUBDIRS; do
177 mkdir -p $EXPECTATIONS_TO_MODIFY_DIR/$SUBDIR
178 cp $COPY_EXPECTATIONS_FROM_DIR/$SUBDIR/expected-results.json \
179 $EXPECTATIONS_TO_MODIFY_DIR/$SUBDIR
180 done
181 COMMAND="python tools/rebaseline.py --expectations-root $EXPECTATIONS_TO_MODIF Y_DIR $ARGS"
182 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
183 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
184 echo $? >$ACTUAL_OUTPUT_DIR/return_value
185
186 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
187 }
188
153 # Run jsondiff.py with arguments in $1, recording its output. 189 # Run jsondiff.py with arguments in $1, recording its output.
154 # Then compare that output to the content of $2/output-expected. 190 # Then compare that output to the content of $2/output-expected.
155 function jsondiff_test { 191 function jsondiff_test {
156 if [ $# != 2 ]; then 192 if [ $# != 2 ]; then
157 echo "jsondiff_test requires exactly 2 parameters, got $#" 193 echo "jsondiff_test requires exactly 2 parameters, got $#"
158 exit 1 194 exit 1
159 fi 195 fi
160 ARGS="$1" 196 ARGS="$1"
161 ACTUAL_OUTPUT_DIR="$2/output-actual" 197 ACTUAL_OUTPUT_DIR="$2/output-actual"
162 EXPECTED_OUTPUT_DIR="$2/output-expected" 198 EXPECTED_OUTPUT_DIR="$2/output-expected"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 echo "skimage self tests failed." 259 echo "skimage self tests failed."
224 exit 1 260 exit 1
225 fi 261 fi
226 262
227 # 263 #
228 # Test rebaseline.py ... 264 # Test rebaseline.py ...
229 # 265 #
230 266
231 REBASELINE_INPUT=tools/tests/rebaseline/input 267 REBASELINE_INPUT=tools/tests/rebaseline/input
232 REBASELINE_OUTPUT=tools/tests/rebaseline/output 268 REBASELINE_OUTPUT=tools/tests/rebaseline/output
233 rebaseline_test "--expectations-root fake/expectations/path --json-base-url file :$REBASELINE_INPUT/json1 --tests test1 test2 --configs 565 8888 --subdirs base-a ndroid-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/subset" 269
234 rebaseline_test "--json-base-url file:nonexistent-path --tests test1 test2" "$RE BASELINE_OUTPUT/all" 270 # These test the old image-file expectations.
235 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and roid-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/using-json1 " 271 rebaseline_images_test "--expectations-root fake/expectations/path --json-base-u rl file:$REBASELINE_INPUT/json1 --tests test1 test2 --configs 565 8888 --subdirs base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/su bset"
236 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and roid-galaxy-nexus base-shuttle-win7-intel-float --add-new" "$REBASELINE_OUTPUT/u sing-json1-add-new" 272 rebaseline_images_test "--json-base-url file:nonexistent-path --tests test1 test 2" "$REBASELINE_OUTPUT/all"
237 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and roid-galaxy-nexus base-shuttle-win7-intel-float --expectations-root $REBASELINE_ INPUT/json1" "$REBASELINE_OUTPUT/using-json1-expectations" 273 rebaseline_images_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs b ase-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/usin g-json1"
274 rebaseline_images_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs b ase-android-galaxy-nexus base-shuttle-win7-intel-float --add-new" "$REBASELINE_O UTPUT/using-json1-add-new"
275
276 # These test the new JSON-format expectations.
277 rebaseline_test "$REBASELINE_INPUT/json1" "--json-base-url file:$REBASELINE_INPU T/json1 --subdirs base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REB ASELINE_OUTPUT/using-json1-expectations"
238 278
239 # 279 #
240 # Test jsondiff.py ... 280 # Test jsondiff.py ...
241 # 281 #
242 282
243 JSONDIFF_INPUT=tools/tests/jsondiff/input 283 JSONDIFF_INPUT=tools/tests/jsondiff/input
244 JSONDIFF_OUTPUT=tools/tests/jsondiff/output 284 JSONDIFF_OUTPUT=tools/tests/jsondiff/output
245 jsondiff_test "$JSONDIFF_INPUT/old.json $JSONDIFF_INPUT/new.json" "$JSONDIFF_OUT PUT/old-vs-new" 285 jsondiff_test "$JSONDIFF_INPUT/old.json $JSONDIFF_INPUT/new.json" "$JSONDIFF_OUT PUT/old-vs-new"
246 286
247 287
248 echo "All tests passed." 288 echo "All tests passed."
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698