Re: [PATCH 1/2] t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'
- Date: Thu, 8 Mar 2018 22:49:50 +0100
- From: SZEDER Gábor <szeder.dev@xxxxxxxxx>
- Subject: Re: [PATCH 1/2] t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'
On Thu, Mar 8, 2018 at 7:51 PM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> On Thu, Mar 8, 2018 at 7:38 AM, SZEDER Gábor <szeder.dev@xxxxxxxxx> wrote:
>> Unroll that for loop, so we can check the files' contents the usual
>> way and rely on 'test_cmp's exit code failing the && chain. Extract
>> updating a file via CVS and verifying its contents using 'test_cmp'
>> into a helper function requiring the file's name as parameter to avoid
>> much of the repetition resulting from unrolling the loop.
> An alternative approach used elsewhere in the test suite 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, like the existing patch, this removes the need for capturing
> test_cmp's output into a "failures" file.)
> : For example, the "setup" test of t2204-add-ignored.sh.
But 't/README' sayeth:
- exit() within a <script> part.
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
Consider the following test script:
-- >8 --
test_expect_success 'exit 1' '
test_expect_success 'second test' '
-- >8 --
FATAL: Unexpected exit with code 1
$ sed -e 's/exit 1/false/' -i t9999-exit.sh
$ ./t9999-exit.sh not ok 1 - false
ok 2 - second test
# failed 1 among 2 test(s)