blob: be8ccf291b53b291903c4dc16356bf6a02f96a97 [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#
7# YOU MUST RE-RUN THIS UNTIL THE SELF-TESTS SUCCEED!
epoger@google.com9c56a8d2012-12-20 18:34:29 +00008# (It takes one run for each failing call to gm_test in run.sh)
9
10function 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
27function 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
41function 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.com8a6f13a2012-12-05 20:21:35 +000052
53# cd into the gm self-test dir
54cd $(dirname $0)
55
56./run.sh
epoger@google.com9c56a8d2012-12-20 18:34:29 +000057SELFTEST_RESULT=$?
58echo
59if [ "$SELFTEST_RESULT" != "0" ]; then
60 replace_expected_with_actual
61 echo "Self-tests still failing, you should probably run this again..."
62else
63 svn_add_new_files
64 svn_delete_old_files
65 echo "Self-tests succeeded this time, you should be done!"
66fi
67exit $SELFTEST_RESULT
epoger@google.com8a6f13a2012-12-05 20:21:35 +000068