Re: [PATCH 09/12] t5520: test single-line files by git with test_cmp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 17, 2019 at 7:17 PM Denton Liu <liu.denton@xxxxxxxxx> wrote:
> In case an invocation of a Git command fails within the subshell, the
> failure will be masked. Replace the subshell with a file-redirection and
> a call to test_cmp.
>
> Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
> ---
> diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
> @@ -622,10 +648,16 @@ test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
>                 git add staged-file &&
> -               test "$(git ls-files)" = staged-file &&
> +               echo staged-file >expect &&
> +               git ls-files >actual &&
> +               test_cmp expect actual &&
>                 test_must_fail git pull --rebase .. master 2>err &&
> -               test "$(git ls-files)" = staged-file &&
> -               test "$(git show :staged-file)" = staged-file &&
> +               echo staged-file >expect &&
> +               git ls-files >actual &&
> +               test_cmp expect actual &&
> +               echo staged-file >expect &&
> +               git show :staged-file >actual &&
> +               test_cmp expect actual &&

Nit: I'm not convinced that it makes sense to re-create the "expect"
file with the exact same content repeatedly in this one test. There is
some value in creating the file once and then _using_ it repeatedly
since that shows intent that the the result of these various commands
is not expected to change.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux