regression: test the new init options
[guilt.git] / regression / run-tests
blob8a265182a40b72a039e71191af089c96570a56e5
1 #!/bin/bash
3 export REG_DIR="$PWD"
4 export PATH="$PWD/bin:$PATH"
6 source scaffold
8 # usage: empty_repo
9 function empty_repo
11 rm -rf $REPODIR
12 mkdir $REPODIR
13 cd $REPODIR > /dev/null
14 git-init-db 2> /dev/null > /dev/null
15 cd - > /dev/null
18 function test_failed
20 cat >&2 <<DONE
21 Test failed!
23 Test: $TESTNAME
24 Repo dir: $REPODIR
25 Log file: $LOGFILE
26 DONE
27 exit 1
30 # usage: run_test <test name>
31 function run_test
33 export REPODIR="/tmp/guilt.reg.$RANDOM"
34 export LOGFILE="/tmp/guilt.log.$RANDOM"
35 export TESTNAME="$1"
37 echo -n "$1: "
39 empty_repo
41 # run the test
42 cd $REPODIR > /dev/null
43 "$REG_DIR/$1" 2>&1 > "$LOGFILE"
44 ERR=$?
45 cd - > /dev/null
47 [ $? -ne 0 ] && test_failed
48 diff -u "`basename $1 .sh`.out" "$LOGFILE" || test_failed
50 echo "done."
52 rm -rf $REPODIR $LOGFILE
55 case "$1" in
56 -h|--help)
57 echo "Usage: $0 [<testnum> [<testnum [<testnum [...]]]]"
58 exit 0
60 esac
62 if [ $# -eq 0 ]; then
63 for t in t-*.sh ; do
64 run_test "$t"
65 done
66 else
67 for t in "$@" ; do
68 run_test "t-$t.sh"
69 done
72 echo "All tests completed."