1 #!/bin/bash 2 3 # Rebaseline the skdiff/*/output-expected/ subdirectories used by the skdiff 4 # self-tests, and similar for benchgraphs/*/output-expected. 5 # 6 # Use with caution: are you sure the new results are actually correct? 7 # 8 # YOU MUST RE-RUN THIS UNTIL THE SELF-TESTS SUCCEED! 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') 15 16 # Replace expected output with actual output, within subdir $1. 17 function replace_expected_with_actual { 18 if [ $# != 1 ]; then 19 echo "replace_expected_with_actual requires exactly 1 parameter, got $#" 20 exit 1 21 fi 22 23 # Delete all the expected output files 24 EXPECTED_FILES=$(find $1/*/output-expected -type f | grep -v /\.svn/) 25 for EXPECTED_FILE in $EXPECTED_FILES; do 26 rm $EXPECTED_FILE 27 done 28 29 # Copy all the actual output files into the "expected" directories, 30 # creating new subdirs as we go. 31 ACTUAL_FILES=$(find $1/*/output-actual -type f | grep -v /\.svn/) 32 for ACTUAL_FILE in $ACTUAL_FILES; do 33 EXPECTED_FILE=${ACTUAL_FILE//actual/expected} 34 mkdir -p $(dirname $EXPECTED_FILE) 35 cp $ACTUAL_FILE $EXPECTED_FILE 36 done 37 } 38 39 # Add all new files to SVN control, within subdir $1. 40 function svn_add_new_files { 41 if [ $# != 1 ]; then 42 echo "svn_add_new_files requires exactly 1 parameter, got $#" 43 exit 1 44 fi 45 46 # Delete all the "actual" directories, so we can svn-add any new "expected" 47 # directories without adding the "actual" ones. 48 rm -rf $1/*/output-actual $1/*/raw-bench-data 49 FILES=$(svn stat $1/* | grep ^\? | awk '{print $2}') 50 for FILE in $FILES; do 51 svn add $FILE 52 done 53 FILES=$(svn stat $1/*/output-expected | grep ^\? | awk '{print $2}') 54 for FILE in $FILES; do 55 svn add $FILE 56 done 57 } 58 59 # For any files that have been removed from subdir $1, remove them from 60 # SVN control. 61 function svn_delete_old_files { 62 if [ $# != 1 ]; then 63 echo "svn_delete_old_files requires exactly 1 parameter, got $#" 64 exit 1 65 fi 66 67 FILES=$(svn stat $1/*/output-expected | grep ^\! | awk '{print $2}') 68 for FILE in $FILES; do 69 svn rm $FILE 70 done 71 FILES=$(svn stat $1/* | grep ^\! | awk '{print $2}') 72 for FILE in $FILES; do 73 svn rm $FILE 74 done 75 } 76 77 78 # cd into the gm self-test dir 79 cd $(dirname $0) 80 81 ./run.sh 82 SELFTEST_RESULT=$? 83 SUBDIRS="skdiff benchgraphs rebaseline/output jsondiff/output" 84 echo 85 if [ "$SELFTEST_RESULT" != "0" ]; then 86 for SUBDIR in $SUBDIRS; do 87 replace_expected_with_actual $SUBDIR 88 done 89 echo "Self-tests still failing, you should probably run this again..." 90 else 91 for SUBDIR in $SUBDIRS; do 92 svn_add_new_files $SUBDIR 93 svn_delete_old_files $SUBDIR 94 done 95 echo "Self-tests succeeded this time, you should be done!" 96 fi 97 exit $SELFTEST_RESULT 98 99