blob: 608e66791aa72c6d6d6381a9675ec50c4e7fc253 [file] [log] [blame]
epoger@google.com8a6f13a2012-12-05 20:21:35 +00001#!/bin/bash
2
3# Rebaseline the outputs/*/output-expected/ subdirectories used by the
4# gm self-tests.
5# Use with caution: are you sure the new results are actually correct?
6#
epoger@google.com3aa33582013-01-02 15:53:25 +00007# TODO: currently, this must be run on Linux to generate baselines that match
8# the ones on the housekeeper bot (which runs on Linux... see
9# http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1417/steps/RunGmSelfTests/logs/stdio )
10# See https://code.google.com/p/skia/issues/detail?id=677
11# ('make tools/tests/run.sh work cross-platform')
epoger@google.com9c56a8d2012-12-20 18:34:29 +000012
13function replace_expected_with_actual {
14 # Delete all the expected output files
15 EXPECTED_FILES=$(find outputs/*/output-expected -type f | grep -v /\.svn/)
16 for EXPECTED_FILE in $EXPECTED_FILES; do
17 rm $EXPECTED_FILE
18 done
19
20 # Copy all the actual output files into the "expected" directories,
21 # creating new subdirs as we go.
22 ACTUAL_FILES=$(find outputs/*/output-actual -type f | grep -v /\.svn/)
23 for ACTUAL_FILE in $ACTUAL_FILES; do
24 EXPECTED_FILE=${ACTUAL_FILE//actual/expected}
25 mkdir -p $(dirname $EXPECTED_FILE)
26 cp $ACTUAL_FILE $EXPECTED_FILE
27 done
28}
29
30function svn_add_new_files {
31 # Delete all the "actual" directories, so we can svn-add any new "expected"
32 # directories without adding the "actual" ones.
33 rm -rf outputs/*/output-actual
34 FILES=$(svn stat outputs/* | grep ^\? | awk '{print $2}')
35 for FILE in $FILES; do
36 svn add $FILE
37 done
38 FILES=$(svn stat outputs/*/output-expected | grep ^\? | awk '{print $2}')
39 for FILE in $FILES; do
40 svn add $FILE
41 done
42}
43
44function svn_delete_old_files {
45 FILES=$(svn stat outputs/*/output-expected | grep ^\! | awk '{print $2}')
46 for FILE in $FILES; do
47 svn rm $FILE
48 done
49 FILES=$(svn stat outputs/* | grep ^\! | awk '{print $2}')
50 for FILE in $FILES; do
51 svn rm $FILE
52 done
53}
54
epoger@google.com8a6f13a2012-12-05 20:21:35 +000055
56# cd into the gm self-test dir
57cd $(dirname $0)
58
59./run.sh
epoger@google.com9c56a8d2012-12-20 18:34:29 +000060SELFTEST_RESULT=$?
61echo
62if [ "$SELFTEST_RESULT" != "0" ]; then
63 replace_expected_with_actual
epoger@google.com9c56a8d2012-12-20 18:34:29 +000064 svn_add_new_files
65 svn_delete_old_files
epoger@google.com0cc99cf2013-04-26 17:45:06 +000066 echo "Rebaseline completed. If you run run.sh now, it should succeed."
67else
68 echo "Self-tests succeeded, nothing to rebaseline."
epoger@google.com9c56a8d2012-12-20 18:34:29 +000069fi
70exit $SELFTEST_RESULT
epoger@google.com8a6f13a2012-12-05 20:21:35 +000071