Re: [PATCH 2/3] t7406: avoid having git commands upstream of a pipe

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

 




> When a git command is on the left side of a pipe, the pipe will swallow
> its exit status, preventing us from detecting failures in said commands.
> Restructure the tests to put the output in a temporary file to avoid
> this problem.
> 
> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  t/t7406-submodule-update.sh | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index e2405c96b5..c8971abd07 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh

> @@ -922,7 +928,7 @@ test_expect_success 'submodule update clone shallow submodule' '
>  		sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
>  		mv -f .gitmodules.tmp .gitmodules &&
>  		git submodule update --init --depth=$commit_count &&
> -		test 1 = $(git -C submodule log --oneline | wc -l)
> +		test 1 = $(git -C submodule rev-list --count HEAD)
>  	)
>  '
> 
> @@ -938,7 +944,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
>  		test_i18ngrep "Direct fetching of that commit failed." actual &&
>  		git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
>  		git submodule update --init --depth=1 >actual &&
> -		test 1 = $(git -C submodule log --oneline | wc -l)
> +		test 1 = $(git -C submodule rev-list --count HEAD)
>  	)
>  '

These two hunks don't have the desired effect, because command
substitutions used like this will hide the exit code anyway.  I'd
suggest

  git -C submodule log --oneline >out &&
  test_line_count = 1 out

instead, with the additional benefit of a nice error message on
failure.





[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