test-lib.sh: Add new function, test_expect_code
The test is considered OK if it exits with code $1 Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
Fredrik Kuivinen committed
Dec 3, 2005 at 11:40 UTC
d3bfdb755e06c04492ad3977e7df3d780b6e02f2
1 file changed
+13
t/test-lib.sh
+13
@@ -133,6 +133,19 @@ test_expect_success () {
133
fi
134
}
135
136
+test_expect_code () {
137
+ test "$#" = 3 ||
138
+ error "bug in the test script: not 3 parameters to test-expect-code"
139
+ say >&3 "expecting exit code $1: $3"
140
+ test_run_ "$3"
141
+ if [ "$?" = 0 -a "$eval_ret" = "$1" ]
142
+ then
143
+ test_ok_ "$2"
144
+ else
145
+ test_failure_ "$@"
146
+ fi
147
+}
148
+
149
test_done () {
150
trap - exit
151
case "$test_failure" in