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