-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-tests.sh
executable file
·74 lines (65 loc) · 1.12 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# change dir to where run.sh is
cd "$(dirname "$0")"
export IT="git extmodule"
export TESTSROOT="$PWD"
export TMPROOT="$PWD/TMP"
export REPOS="$TMPROOT"
export WORK="$TMPROOT/work"
export HOME="$WORK"
if [ -n "$*" ]
then
tests=("$@")
else
tests=$(ls tests/test*.sh | sort)
fi
set -e
setup() (
rm -rf "$TMPROOT"
mkdir -p "$WORK"
git config --global user.email "[email protected]"
git config --global user.name "Run Tests Sh"
for r in sub1 sub2; do
(
REPO="$TMPROOT/$r"
set -e
mkdir -p "$REPO"
cd "$REPO"
git init
for n in 1 2 3; do
f="$r-$n"
touch $f
git add $f
git commit -m "added $f"
done
git checkout -b alternate master^^
touch alternate-$r
git add alternate-$r
git commit -m "added alternate-$r"
git checkout master
)
done >"$WORK"/SETUP.OUT 2>&1
)
runtest() (
set -e
TEST="$TESTSROOT/$1"
PATH="$PWD:$PATH"
setup
cd "$WORK"
echo "* Running test '$TEST'"
if "$TEST" >RUN.OUT 2>&1
then
exit 0
else
echo "* TEST '$TEST' FAILED. OUTPUT:"
echo
cat RUN.OUT
echo
exit 1
fi
)
for t in $tests
do
runtest "$t"
done
echo "** All tests OK"