blob: c3c5bbc9990834e5b1729facef03c245e0e203dd [file] [log] [blame]
epoger@google.coma2b793c2012-05-15 14:58:53 +00001#!/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
8SKDIFF_BINARY=out/Debug/skdiff
9
epoger@google.coma4443522012-05-17 17:12:38 +000010# 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.coma2b793c2012-05-15 14:58:53 +000015function 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.coma4443522012-05-17 17:12:38 +000023# 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.
26function skdiff_test {
27 SKDIFF_ARGS="$1"
28 ACTUAL_OUTPUT_DIR="$2/output-actual"
29 EXPECTED_OUTPUT_DIR="$2/output-expected"
epoger@google.coma2b793c2012-05-15 14:58:53 +000030
epoger@google.coma4443522012-05-17 17:12:38 +000031 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
37SKDIFF_TESTDIR=tools/tests/skdiff
38skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
epoger@google.coma2b793c2012-05-15 14:58:53 +000039echo "All tests passed."