epoger@google.com | 8a6f13a | 2012-12-05 20:21:35 +0000 | [diff] [blame] | 1 | #!/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.com | 3aa3358 | 2013-01-02 15:53:25 +0000 | [diff] [blame] | 7 | # 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.com | 9c56a8d | 2012-12-20 18:34:29 +0000 | [diff] [blame] | 12 | |
| 13 | function 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 | |
| 30 | function 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 | |
| 44 | function 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.com | 8a6f13a | 2012-12-05 20:21:35 +0000 | [diff] [blame] | 55 | |
| 56 | # cd into the gm self-test dir |
| 57 | cd $(dirname $0) |
| 58 | |
| 59 | ./run.sh |
epoger@google.com | 9c56a8d | 2012-12-20 18:34:29 +0000 | [diff] [blame] | 60 | SELFTEST_RESULT=$? |
| 61 | echo |
| 62 | if [ "$SELFTEST_RESULT" != "0" ]; then |
| 63 | replace_expected_with_actual |
epoger@google.com | 9c56a8d | 2012-12-20 18:34:29 +0000 | [diff] [blame] | 64 | svn_add_new_files |
| 65 | svn_delete_old_files |
epoger@google.com | 0cc99cf | 2013-04-26 17:45:06 +0000 | [diff] [blame] | 66 | echo "Rebaseline completed. If you run run.sh now, it should succeed." |
| 67 | else |
| 68 | echo "Self-tests succeeded, nothing to rebaseline." |
epoger@google.com | 9c56a8d | 2012-12-20 18:34:29 +0000 | [diff] [blame] | 69 | fi |
| 70 | exit $SELFTEST_RESULT |
epoger@google.com | 8a6f13a | 2012-12-05 20:21:35 +0000 | [diff] [blame] | 71 | |