| 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) |
| 9 | |
| 10 | function replace_expected_with_actual { |
| 11 | # Delete all the expected output files |
| 12 | EXPECTED_FILES=$(find outputs/*/output-expected -type f | grep -v /\.svn/) |
| 13 | for EXPECTED_FILE in $EXPECTED_FILES; do |
| 14 | rm $EXPECTED_FILE |
| 15 | done |
| 16 | |
| 17 | # Copy all the actual output files into the "expected" directories, |
| 18 | # creating new subdirs as we go. |
| 19 | ACTUAL_FILES=$(find outputs/*/output-actual -type f | grep -v /\.svn/) |
| 20 | for ACTUAL_FILE in $ACTUAL_FILES; do |
| 21 | EXPECTED_FILE=${ACTUAL_FILE//actual/expected} |
| 22 | mkdir -p $(dirname $EXPECTED_FILE) |
| 23 | cp $ACTUAL_FILE $EXPECTED_FILE |
| 24 | done |
| 25 | } |
| 26 | |
| 27 | function svn_add_new_files { |
| 28 | # Delete all the "actual" directories, so we can svn-add any new "expected" |
| 29 | # directories without adding the "actual" ones. |
| 30 | rm -rf outputs/*/output-actual |
| 31 | FILES=$(svn stat outputs/* | grep ^\? | awk '{print $2}') |
| 32 | for FILE in $FILES; do |
| 33 | svn add $FILE |
| 34 | done |
| 35 | FILES=$(svn stat outputs/*/output-expected | grep ^\? | awk '{print $2}') |
| 36 | for FILE in $FILES; do |
| 37 | svn add $FILE |
| 38 | done |
| 39 | } |
| 40 | |
| 41 | function svn_delete_old_files { |
| 42 | FILES=$(svn stat outputs/*/output-expected | grep ^\! | awk '{print $2}') |
| 43 | for FILE in $FILES; do |
| 44 | svn rm $FILE |
| 45 | done |
| 46 | FILES=$(svn stat outputs/* | grep ^\! | awk '{print $2}') |
| 47 | for FILE in $FILES; do |
| 48 | svn rm $FILE |
| 49 | done |
| 50 | } |
| 51 | |
| epoger@google.com | 8a6f13a | 2012-12-05 20:21:35 +0000 | [diff] [blame] | 52 | |
| 53 | # cd into the gm self-test dir |
| 54 | cd $(dirname $0) |
| 55 | |
| 56 | ./run.sh |
| epoger@google.com | 9c56a8d | 2012-12-20 18:34:29 +0000 | [diff] [blame^] | 57 | SELFTEST_RESULT=$? |
| 58 | echo |
| 59 | if [ "$SELFTEST_RESULT" != "0" ]; then |
| 60 | replace_expected_with_actual |
| 61 | echo "Self-tests still failing, you should probably run this again..." |
| 62 | else |
| 63 | svn_add_new_files |
| 64 | svn_delete_old_files |
| 65 | echo "Self-tests succeeded this time, you should be done!" |
| 66 | fi |
| 67 | exit $SELFTEST_RESULT |
| epoger@google.com | 8a6f13a | 2012-12-05 20:21:35 +0000 | [diff] [blame] | 68 | |