Git fork

test-lib tests: assert 1 exit code, not non-zero

Improve the testing for test-lib.sh itself to assert that we have a
exit code of 1, not any non-zero. Improves code added in
0445e6f0a12 (test-lib: '--run' to run only specific tests,
2014-04-30).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Ævar Arnfjörð Bjarmason and committed by
Junio C Hamano
56722a06 e07b817c

+9 -12
+9 -12
t/lib-subtest.sh
··· 11 11 } 12 12 13 13 _run_sub_test_lib_test_common () { 14 - neg="$1" name="$2" # stdin is the body of the test code 15 - shift 2 14 + cmp_op="$1" want_code="$2" name="$3" # stdin is the body of the test code 15 + shift 3 16 16 17 17 # intercept pseudo-options at the front of the argument list that we 18 18 # will not pass to child script ··· 48 48 GIT_SKIP_TESTS=$skip && 49 49 export GIT_SKIP_TESTS && 50 50 sane_unset GIT_TEST_FAIL_PREREQS && 51 - if test -z "$neg" 52 - then 53 - ./"$name.sh" "$@" >out 2>err 54 - else 55 - ! ./"$name.sh" "$@" >out 2>err 56 - fi 51 + ./"$name.sh" "$@" >out 2>err; 52 + ret=$? && 53 + test "$ret" "$cmp_op" "$want_code" 57 54 ) 58 55 } 59 56 60 57 write_and_run_sub_test_lib_test () { 61 58 name="$1" descr="$2" # stdin is the body of the test code 62 59 write_sub_test_lib_test "$@" || return 1 63 - _run_sub_test_lib_test_common '' "$@" 60 + _run_sub_test_lib_test_common -eq 0 "$@" 64 61 } 65 62 66 63 write_and_run_sub_test_lib_test_err () { 67 64 name="$1" descr="$2" # stdin is the body of the test code 68 65 write_sub_test_lib_test "$@" || return 1 69 - _run_sub_test_lib_test_common '!' "$@" 66 + _run_sub_test_lib_test_common -eq 1 "$@" 70 67 } 71 68 72 69 run_sub_test_lib_test () { 73 - _run_sub_test_lib_test_common '' "$@" 70 + _run_sub_test_lib_test_common -eq 0 "$@" 74 71 } 75 72 76 73 run_sub_test_lib_test_err () { 77 - _run_sub_test_lib_test_common '!' "$@" 74 + _run_sub_test_lib_test_common -eq 1 "$@" 78 75 } 79 76 80 77 _check_sub_test_lib_test_common () {