summaryrefslogtreecommitdiffstats
path: root/git-check-commit-msg/run-tests.sh
blob: 3b43f16c6973127b6a838d27d93efa54da3d6e3d (plain)
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
#!/bin/sh

tcdir="${top_srcdir-.}"
script="${top_srcdir-.}/git-check-commit-msg/git-check-commit-msg"

errors=0

while read tc expect restofline
do
	tcfile="${tcdir}/git-check-commit-msg/${tc}"
	test -f "$tcfile" || {
		echo "$0: Fatal: Test file $tcfile not found." >&2
		exit 1
	}

	"$script" "$tcfile"; s="$?"

	if   [ "$s" -eq 0 ] && [ "x$expect" = "xOK" ]; then :;
	elif [ "$s" -ne 0 ] && [ "x$expect" = "xFAIL" ]; then :;
	else
		sh -x "$script" "$tcfile"
		echo "TC: $tc expected $expect, but deviates."
		errors="$(expr $errors + 1)"
	fi
done<<EOF
commit-1	OK
commit-2	FAIL
commit-3	OK
EOF

[ "$errors" -ne 0 ] && exit 1
exit 0