tests: print the actions to see what is being done (and what has failed precisely).
[gitgitconfig.git] / run-tests.sh
blob7aca47840d532e5cddcd36e17cbb59ab0786a7a3
1 #!/bin/bash -e
3 SRCDIR="$(dirname "$0")"
5 absolute() {
6 case "$1" in
7 /*)
8 echo "$1"
9 ;;
11 echo "$(pwd)/$t"
13 esac
16 SRCDIR="$(absolute "$SRCDIR")"
17 readonly SRCDIR
19 # Set env for the scripts and test scripts:
20 readonly DATADIR="$SRCDIR"
21 if [[ "$PATH" ]]; then
22 readonly PATH="$SRCDIR:$PATH"
23 else
24 readonly PATH="$SRCDIR"
26 export DATADIR PATH
28 if [[ "$1" ]]; then
29 readonly TESTS=("$@")
30 else
31 readonly TESTS=("$SRCDIR"/tests/*.sh)
34 for t in "${TESTS[@]}"; do
35 echo -n "################################### "
36 echo "Running $(basename "$t")..."
37 t="$(absolute "$t")"
38 rm -rf "$TMP"/test-gitgitconfig
39 mkdir "$TMP"/test-gitgitconfig
40 pushd "$TMP"/test-gitgitconfig
41 if "$t"; then echo OK; else echo FAILED; exit 1; fi
42 popd
43 rm -rf "$TMP"/test-gitgitconfig
44 done