| epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Tests for our tools. |
| 4 | # TODO: for now, it only tests skdiff |
| 5 | # TODO: for now, assumes that it is being run from .../trunk |
| 6 | |
| 7 | # TODO: make it look in Release and/or Debug |
| 8 | SKDIFF_BINARY=out/Debug/skdiff |
| 9 | |
| epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame^] | 10 | # Compare contents of all files within directories $1 and $2, |
| 11 | # EXCEPT for any dotfiles. |
| 12 | # If there are any differences, a description is written to stdout and |
| 13 | # we exit with a nonzero return value. |
| 14 | # Otherwise, we write nothing to stdout and return. |
| epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 15 | function compare_directories { |
| 16 | diff --exclude=.* $1 $2 |
| 17 | if [ $? != 0 ]; then |
| 18 | echo "failed in: compare_directories $1 $2" |
| 19 | exit 1 |
| 20 | fi |
| 21 | } |
| 22 | |
| epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame^] | 23 | # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff |
| 24 | # to write its output, if any, to directory $2/output-actual). |
| 25 | # Then compare its results against those in $2/output-expected. |
| 26 | function skdiff_test { |
| 27 | SKDIFF_ARGS="$1" |
| 28 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 29 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
| epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 30 | |
| epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame^] | 31 | rm -rf $ACTUAL_OUTPUT_DIR |
| 32 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 33 | $SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR &>$ACTUAL_OUTPUT_DIR/stdout |
| 34 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 35 | } |
| 36 | |
| 37 | SKDIFF_TESTDIR=tools/tests/skdiff |
| 38 | skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1" |
| epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 39 | echo "All tests passed." |