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

Re: [PATCH 2/4] test-lib: allow variable export from lazy prereq tests

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 16, 2012, 16:16 UTC
Message-ID
<7vipaatmsb.fsf@alter.siamese.dyndns.org>
In-Reply-To
<ca07c5a1cf836826fc0ee53daf3e7f3dfe111ece.1350387132.git.git@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
> I don't think this has any adverse side effects, but I'm begging for
> another set of eyeballs to have a look. (Test suite passes, of course.)

The lazy prereqs are designed to be used lazily, in any test that he who wrote lazy-prereq did not anticipate. It is run inside a subshell to make it absolutely sure that whatever it does (like use of shell variables, chdir around) will not be able to affect _any_ calling context that is not anticipated by who writes lazy prerequisite.

Please don't do this.
Show 26 quoted lines
>
>  t/test-lib-functions.sh | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 8889ba5..e587902 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -246,13 +246,15 @@ test_lazy_prereq () {
>  test_run_lazy_prereq_ () {
>  	script='
>  mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" &&
> -(
> +{
>  	cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"'
> -)'
> +}'
>  	say >&3 "checking prerequisite: $1"
>  	say >&3 "$script"
> +	orig_pwd="$(pwd)"
>  	test_eval_ "$script"
>  	eval_ret=$?
> +	cd "$orig_pwd"
>  	rm -rf "$TRASH_DIRECTORY/prereq-test-dir"
>  	if test "$eval_ret" = 0; then
>  		say >&3 "prerequisite $1 ok"
Previous: Michael J GruberNext: Michael J Gruber
Message 6 of 17 in “t3302-notes-index-expensive.sh and t3419-rebase-patch-id.sh need time in /usr/bin”
  1. Joachim SchmitzOct 15, 2012
  2. 0/4 Allow different time commandsMichael J Gruber, Oct 16, 2012
  3. 1/4 t3419-rebase-patch-id: heed USR_BIN_TIME prereqMichael J Gruber, Oct 16, 2012
  4. Junio C HamanoOct 16, 2012
  5. 2/4 test-lib: allow variable export from lazy prereq testsMichael J Gruber, Oct 16, 2012
  6. Junio C HamanoOct 16, 2012
  7. 3/4 test-lib: provide lazy TIME_COMMAND prereqMichael J Gruber, Oct 16, 2012
  8. Joachim SchmitzOct 16, 2012
  9. Michael J GruberOct 16, 2012
  10. Joachim SchmitzOct 16, 2012
  11. test-lib: provide lazy TIME_COMMAND prereqMichael J Gruber, Oct 16, 2012
  12. Andreas SchwabOct 16, 2012
  13. Stefano LattariniOct 16, 2012
  14. Johannes SixtOct 16, 2012
  15. Junio C HamanoOct 16, 2012
  16. Junio C HamanoOct 16, 2012
  17. 4/4 t3302,t3419: use the TIME_COMMAND prereqMichael J Gruber, Oct 16, 2012

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.