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

Re: [PATCH v3 1/2] rev-parse tests: add tests executed from a subdirectory

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2016, 22:10 UTC
Message-ID
<xmqqy47m25z4.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1462541720-79553-2-git-send-email-rappazzo@gmail.com>
Michael Rappazzo <rappazzo@gmail.com> writes:
> t1500-rev-parse contains envrionment leaks (changing dir without
> changing back, setting config variables, etc).  Add a test to clean this
> up up so that future tests can be added without worry of any setting
> from a previous test.
This is a wonderful thing to do, but...
Show 9 quoted lines
>  test_rev_parse toplevel false false true '' .git
>  
> @@ -84,4 +85,41 @@ test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
>  git config --unset core.bare
>  test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
>  
> +test_expect_success 'cleanup from the previous tests' '
> +	cd .. &&
> +	rm -r work &&

Instead of cleaning things up like this, could you please please please fix these existing tests that chdir around without being in a subshell? If the "previous tests" failed before going down as this step expects, the "cd .. && rm -r" can make things worse.

> +	mv repo.git .git &&
> +	unset GIT_DIR &&
> +	unset GIT_CONFIG &&

The spirit of this change is to make the test more independent from the effects of what happened previously. Use sane_unset so that we do not have to worry about previous step that may have failed before it has a chance to set GIT_DIR and GIT_CONFIG (which would cause these unset to fail).

> +	git config core.bare $original_core_bare

Is this (rather, the capturing of $original_core_bare up above) necessary? We are in the default 'trash' repository when the capturing happens, and we know it is not a bare repository, right?

Previous: Michael RappazzoNext: Mike Rappazzo
Message 3 of 8 in “rev-parse: fix some options when executed from subpath of main tree”
  1. 0/2 [PATCH v3 0/2] rev-parse: fix some options when executed from subpath of main treeMichael Rappazzo, May 6, 2016
  2. 1/2 rev-parse tests: add tests executed from a subdirectoryMichael Rappazzo, May 6, 2016
  3. Junio C HamanoMay 6, 2016
  4. Mike RappazzoMay 7, 2016
  5. Junio C HamanoMay 8, 2016
  6. Junio C HamanoMay 8, 2016
  7. 2/2 rev-parse: fix some options when executed from subpath of main treeMichael Rappazzo, May 6, 2016
  8. Eric SunshineMay 10, 2016

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.