2012-05-15 14:58:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for our tools.
|
|
|
|
# TODO: for now, it only tests skdiff
|
2012-11-12 18:04:51 +00:00
|
|
|
|
|
|
|
# cd into .../trunk so all the paths will work
|
|
|
|
cd $(dirname $0)/../..
|
2012-05-15 14:58:53 +00:00
|
|
|
|
|
|
|
# TODO: make it look in Release and/or Debug
|
|
|
|
SKDIFF_BINARY=out/Debug/skdiff
|
|
|
|
|
2012-05-17 17:12:38 +00:00
|
|
|
# Compare contents of all files within directories $1 and $2,
|
|
|
|
# EXCEPT for any dotfiles.
|
|
|
|
# If there are any differences, a description is written to stdout and
|
|
|
|
# we exit with a nonzero return value.
|
|
|
|
# Otherwise, we write nothing to stdout and return.
|
2012-05-15 14:58:53 +00:00
|
|
|
function compare_directories {
|
2012-11-12 18:04:51 +00:00
|
|
|
if [ $# != 2 ]; then
|
|
|
|
echo "compare_directories requires exactly 2 parameters, got $#"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-05-15 14:58:53 +00:00
|
|
|
diff --exclude=.* $1 $2
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "failed in: compare_directories $1 $2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-05-17 17:12:38 +00:00
|
|
|
# Run skdiff with arguments in $1 (plus implicit final argument causing skdiff
|
|
|
|
# to write its output, if any, to directory $2/output-actual).
|
|
|
|
# Then compare its results against those in $2/output-expected.
|
|
|
|
function skdiff_test {
|
2012-11-12 18:04:51 +00:00
|
|
|
if [ $# != 2 ]; then
|
|
|
|
echo "skdiff_test requires exactly 2 parameters, got $#"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-05-17 17:12:38 +00:00
|
|
|
SKDIFF_ARGS="$1"
|
|
|
|
ACTUAL_OUTPUT_DIR="$2/output-actual"
|
|
|
|
EXPECTED_OUTPUT_DIR="$2/output-expected"
|
|
|
|
|
|
|
|
rm -rf $ACTUAL_OUTPUT_DIR
|
|
|
|
mkdir -p $ACTUAL_OUTPUT_DIR
|
2012-05-18 18:25:26 +00:00
|
|
|
COMMAND="$SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR"
|
|
|
|
echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
|
|
|
|
$COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
|
|
|
|
echo $? >$ACTUAL_OUTPUT_DIR/return_value
|
|
|
|
|
2012-05-17 17:12:38 +00:00
|
|
|
compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
|
|
|
|
}
|
2012-05-15 14:58:53 +00:00
|
|
|
|
2012-05-17 17:12:38 +00:00
|
|
|
SKDIFF_TESTDIR=tools/tests/skdiff
|
2012-05-30 19:12:45 +00:00
|
|
|
|
2012-07-13 21:22:02 +00:00
|
|
|
# Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from
|
|
|
|
# baseDir, etc.
|
2012-05-17 17:12:38 +00:00
|
|
|
skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
|
2012-05-30 19:12:45 +00:00
|
|
|
|
2012-07-13 21:22:02 +00:00
|
|
|
# Run skdiff over the same set of files, but with arguments as used by our buildbots:
|
|
|
|
# - return the number of mismatching file pairs (but ignore any files missing from either
|
|
|
|
# baseDir or comparisonDir)
|
2012-07-12 18:16:02 +00:00
|
|
|
# - list filenames with each result type to stdout
|
|
|
|
# - don't generate HTML output files
|
2012-12-05 20:13:12 +00:00
|
|
|
skdiff_test "--failonresult DifferentPixels --failonresult DifferentSizes --failonresult Unknown --failonstatus CouldNotDecode,CouldNotRead any --failonstatus any CouldNotDecode,CouldNotRead --listfilenames --nodiffs $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test2"
|
2012-05-30 19:12:45 +00:00
|
|
|
|
2012-07-13 21:22:02 +00:00
|
|
|
# Run skdiff over just the files that have identical bits.
|
|
|
|
skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits"
|
2012-05-30 19:12:45 +00:00
|
|
|
|
2012-07-13 21:22:02 +00:00
|
|
|
# Run skdiff over just the files that have identical bits or identical pixels.
|
|
|
|
skdiff_test "--nodiffs --match identical-bits --match identical-pixels $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits-or-pixels"
|
2012-05-30 19:12:45 +00:00
|
|
|
|
2012-05-15 14:58:53 +00:00
|
|
|
echo "All tests passed."
|