blob: eee8db87c1ede2c5668ed5dc8ed209abbd9a24c6 [file] [log] [blame]
rmistry@google.comee5a5ee2013-01-03 19:23:22 +00001#!/bin/bash
2
3# Rebaseline the skdiff/*/output-expected/ subdirectories used by the skdiff
4# self-tests.
5# Use with caution: are you sure the new results are actually correct?
6#
7# YOU MUST RE-RUN THIS UNTIL THE SELF-TESTS SUCCEED!
8#
9# TODO: currently, this must be run on Linux to generate baselines that match
10# the ones on the housekeeper bot (which runs on Linux... see
11# http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1417/steps/RunGmSelfTests/logs/stdio )
12# See https://code.google.com/p/skia/issues/detail?id=677
13# ('make tools/tests/run.sh work cross-platform')
14
15function replace_expected_with_actual {
16 # Delete all the expected output files
17 EXPECTED_FILES=$(find skdiff/*/output-expected -type f | grep -v /\.svn/)
18 for EXPECTED_FILE in $EXPECTED_FILES; do
19 rm $EXPECTED_FILE
20 done
21
22 # Copy all the actual output files into the "expected" directories,
23 # creating new subdirs as we go.
24 ACTUAL_FILES=$(find skdiff/*/output-actual -type f | grep -v /\.svn/)
25 for ACTUAL_FILE in $ACTUAL_FILES; do
26 EXPECTED_FILE=${ACTUAL_FILE//actual/expected}
27 mkdir -p $(dirname $EXPECTED_FILE)
28 cp $ACTUAL_FILE $EXPECTED_FILE
29 done
30}
31
32function svn_add_new_files {
33 # Delete all the "actual" directories, so we can svn-add any new "expected"
34 # directories without adding the "actual" ones.
35 rm -rf skdiff/*/output-actual
36 FILES=$(svn stat skdiff/* | grep ^\? | awk '{print $2}')
37 for FILE in $FILES; do
38 svn add $FILE
39 done
40 FILES=$(svn stat skdiff/*/output-expected | grep ^\? | awk '{print $2}')
41 for FILE in $FILES; do
42 svn add $FILE
43 done
44}
45
46function svn_delete_old_files {
47 FILES=$(svn stat skdiff/*/output-expected | grep ^\! | awk '{print $2}')
48 for FILE in $FILES; do
49 svn rm $FILE
50 done
51 FILES=$(svn stat skdiff/* | grep ^\! | awk '{print $2}')
52 for FILE in $FILES; do
53 svn rm $FILE
54 done
55}
56
57
58# cd into the gm self-test dir
59cd $(dirname $0)
60
61./run.sh
62SELFTEST_RESULT=$?
63echo
64if [ "$SELFTEST_RESULT" != "0" ]; then
65 replace_expected_with_actual
66 echo "Self-tests still failing, you should probably run this again..."
67else
68 svn_add_new_files
69 svn_delete_old_files
70 echo "Self-tests succeeded this time, you should be done!"
71fi
72exit $SELFTEST_RESULT
73