On 26 June 2018 at 08:29, Eric Sunshine <sunsh...@sunshineco.com> wrote:
> These tests intentionally break the &&-chain to manually check the exit
> code of invoked commands which they expect to fail, and invert that
> local expected failure into a successful exit code for the test overall.
> Such manual exit code manipulation predates the invention of
> test_must_fail().
>
> An upcoming change will teach --chain-lint to check the &&-chain inside
> subshells. This sort of manual exit code checking will trip up
> --chain-lint due to the intentional break in the &&-chain. Therefore,
> replace the manual exit code management with test_must_fail() and a
> normal &&-chain.
>
> Signed-off-by: Eric Sunshine <sunsh...@sunshineco.com>
> ---
>  t/t5405-send-pack-rewind.sh |  3 +--
>  t/t9814-git-p4-rename.sh    | 16 ++--------------
>  2 files changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/t/t5405-send-pack-rewind.sh b/t/t5405-send-pack-rewind.sh
> index 4bda18a662..235fb7686a 100755
> --- a/t/t5405-send-pack-rewind.sh
> +++ b/t/t5405-send-pack-rewind.sh
> @@ -25,8 +25,7 @@ test_expect_success 'non forced push should die not 
> segfault' '
>
>         (
>                 cd another &&
> -               git push .. master:master
> -               test $? = 1
> +               test_must_fail git push .. master:master
>         )
>
>  '
> diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
> index e7e0268e98..80aac5ab16 100755
> --- a/t/t9814-git-p4-rename.sh
> +++ b/t/t9814-git-p4-rename.sh
> @@ -12,20 +12,8 @@ test_expect_success 'start p4d' '
>  test_expect_success 'p4 help unknown returns 1' '
>         (
>                 cd "$cli" &&
> -               (
> -                       p4 help client >errs 2>&1
> -                       echo $? >retval
> -               )
> -               echo 0 >expected &&
> -               test_cmp expected retval &&
> -               rm retval &&
> -               (
> -                       p4 help nosuchcommand >errs 2>&1
> -                       echo $? >retval
> -               )
> -               echo 1 >expected &&
> -               test_cmp expected retval &&
> -               rm retval
> +               p4 help client &&
> +               test_must_fail p4 help nosuchcommand

This seems a lot more sensible. It works fine in my tests.

Thanks,
Luke

Reply via email to