git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 2 of 7 in “test-lib: Multi-prereq support only checked the last prereq”
  1. test-lib: Multi-prereq support only checked the last prereqÆvar Arnfjörð Bjarmason, Aug 10, 2010
  2. Jonathan NiederAug 11, 2010
  3. test-lib: Multi-prereq support only checked the last prereqÆvar Arnfjörð Bjarmason, Aug 11, 2010
  4. Johannes SixtAug 13, 2010
  5. tests: simplify "missing PREREQ" messageJonathan Nieder, Aug 24, 2010
  6. Johannes SixtAug 24, 2010
  7. Junio C HamanoAug 24, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.