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

Re: [PATCH] tests: set temp variables using 'env' in test function instead of subshell

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2014, 20:57 UTC
Message-ID
<xmqqeh20czl9.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1395046593-4057-1-git-send-email-unsignedzero@gmail.com>
David Tran <unsignedzero@gmail.com> writes:
> Fixed the broken &&-chain and the tests run correctly. The double env is
> fixed to be a single env. The useless subshells are removed.
> ...
Hmph.
Show 8 quoted lines
>  test_expect_success 'need valid notes ref' '
> -	(MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
> -	 test_must_fail git notes add) &&
> -	(MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
> -	 test_must_fail git notes show)
> +	test_must_fail env MSG=1 env GIT_NOTES_REF=/ git notes show &&
> +	test_must_fail env MSG=2 env GIT_NOTES_REF=/ git notes show
>  '
Oh, really ;-)?
Show 6 quoted lines
>  test_expect_success 'refusing to add notes in refs/heads/' '
> -	(MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
> -	 export MSG GIT_NOTES_REF &&
> -	 test_must_fail git notes add)
> +	test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes add
>  '
This one is good.
Show 9 quoted lines
> @@ -529,9 +510,7 @@ test_expect_success 'aborted --continue does not squash commits after "edit"' '
>  	echo "edited again" > file7 &&
>  	git add file7 &&
>  	(
> -		FAKE_COMMIT_MESSAGE=" " &&
> -		export FAKE_COMMIT_MESSAGE &&
> -		test_must_fail git rebase --continue
> +		test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue
>  	) &&

Do we do anything to cause us misbehave if the above is done outside the subshell?

Thanks.  Getting closer, I think.
Previous: David Tran
Message 2 of 2 in “tests: set temp variables using 'env' in test function instead of subshell”
  1. tests: set temp variables using 'env' in test function instead of subshellDavid Tran, Mar 17, 2014
  2. Junio C HamanoMar 17, 2014

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.