Re: [PATCH 6/8] t: simplify loop exit-code status variables

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

 



Jeff King <peff@xxxxxxxx> writes:

> Since shell loops may drop the exit code of failed commands
> inside the loop, some tests try to keep track of the status
> by setting a variable. This can end up cumbersome and hard
> to read; it is much simpler to just exit directly from the
> loop using "return 1" (since each case is either in a helper
> function or inside a test snippet).
>
> Signed-off-by: Jeff King <peff@xxxxxxxx>
> ---
>  t/t3060-ls-files-with-tree.sh | 13 ++++---------
>  t/t3901-i18n-patch.sh         |  8 ++------
>  2 files changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh
> index 61c1f53..36b10f7 100755
> --- a/t/t3060-ls-files-with-tree.sh
> +++ b/t/t3060-ls-files-with-tree.sh
> @@ -25,15 +25,10 @@ test_expect_success setup '
>  		do
>  			num=00$n$m &&
>  			>sub/file-$num &&
> -			echo file-$num >>expected || {
> -				bad=t
> -				break
> -			}
> -		done && test -z "$bad" || {
> -			bad=t
> -			break
> -		}
> -	done && test -z "$bad" &&
> +			echo file-$num >>expected ||
> +			return 1
> +		done
> +	done &&
>  	git add . &&
>  	git commit -m "add a bunch of files" &&

The empty initialization for $bad can also go for this one, right?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]