On Thu, Mar 8, 2018 at 4:49 PM, SZEDER Gábor <szeder....@gmail.com> wrote:
> On Thu, Mar 8, 2018 at 7:51 PM, Eric Sunshine <sunsh...@sunshineco.com> wrote:
>> An alternative approach used elsewhere in the test suite[1] would be
>> simply to 'exit' if test_cmp fails:
>>
>>     for i in merge no-lf empty really-empty; do
>>         GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out
>>         test_cmp $i.out ../$i || exit 1
>>     done &&
>
> And it's right: 'exit' terminates the shell process it's invoked in,
> i.e. the whole test script (well, unless it's invoked in a subshell)
> without executing the remaining tests and the usual housekeeping and
> reporting.
>
> Consider the following test script:
>
>   $ ./t9999-exit.sh
>   FATAL: Unexpected exit with code 1

Sorry for the confusion. I meant "return 1" as used elsewhere in the
test suite[1].

--- >8 ---
#!/bin/sh
test_description='return 1?'
. ./test-lib.sh

test_expect_success 'return 1' '
        return 1
'

test_expect_success 'second test' '
        true
'

test_done
--- >8 ---

$ ./t9977.sh
not ok 1 - return 1
#
#         return 1
#
ok 2 - second test
# failed 1 among 2 test(s)
1..2
$

[1]: For example, the "setup" test of t4151-am-abort.sh.

Reply via email to