Re: [PATCH] test-lib: Multi-prereq support only checked the last prereq

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

 



Ævar Arnfjörð Bjarmason wrote:

> The clever for-loop (which I blindly copied from Junio)

You did not copy his “return” statement, though. :)

> +++ b/t/test-lib.sh
> @@ -337,15 +337,30 @@ test_have_prereq () {
>  	IFS=,
>  	set -- $*
>  	IFS=$save_IFS
> +
> +	total_prereq=0
> +	ok_prereq=0
> +	missing_prereq=
> +
>  	for prerequisite
>  	do
> +		total_prereq=$(($total_prereq + 1))
>  		case $satisfied in
>  		*" $prerequisite "*)
> -			: yes, have it ;;
> +			ok_prereq=$(($ok_prereq + 1))
> +			;;
>  		*)
> -			! : nope ;;
> +			# Keep a list of missing prerequisites
> +			if test -z "$missing_prereq"
> +			then
> +				missing_prereq=$prerequisite
> +			else
> +				missing_prereq="$prerequisite,$missing_prereq"
> +			fi
>  		esac
>  	done
> +
> +	test $total_prereq = $ok_prereq
>  }

Wouldn’t

-		! : nope ;;
+		return 1 ;;

be simpler?

This and a small cleanup, including a test that catches this, are at
http://thread.gmane.org/gmane.comp.version-control.git/152814/focus=152875

Hope that helps,
Jonathan
--
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]