Re: [PATCH] test-lib: Multi-prereq support only checked the last prereq
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Aug 11, 2010, 01:43 UTC
- Message-ID
- <20100811014325.GA4169@burratino>
- In-Reply-To
- <1281482511-2461-1-git-send-email-avarab@gmail.com>
Ævar Arnfjörð Bjarmason wrote:
> The clever for-loop (which I blindly copied from Junio)
You did not copy his “return” statement, though. :)
Show 32 quoted lines
> +++ 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