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

Re: [PATCH 1/2] t1300: put git invocations inside test function

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 19, 2011, 07:04 UTC
Message-ID
<7vzkgxcviz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4E9E7115.60303@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 11 quoted lines
> This innocently looking hunk fails on Windows, because the preceding tests
> are skipped, and .git/config does not exist. I was tempted to just change
> this to 'rm -f'. But there are a few other instances of 'rm .git/config'
> in this file that were *not* moved inside the test function.
>
> How would you like this solved?
>
> - Move this one out again
> - Add -f to just this one
> - Add -f everywhere
> - a combination of the above?

Probably "rm -f .git/config" to all tests would be the most appropriate, as the desire to start from an empty config file is a sign that each test wants to be as independent as possible from previous tests.

An alternative approach to achieve the independence would be to make each test responsible for cleaning up after itself, with test_when_finished, but that won't work for the first one, as the test framework would give you the original one. Besides, that's trying to be cooperative when each test can fail in an unexpected way (after all the purpose of tests is to fail when things go wrong). In order to achieve isolation, each test protecting themselves from others, as long as it can be easily and reasonably done (e.g. a single "rm -f"), is probably far more preferrable than each test trying to clean after itself, risking possible failure to do so.

Previous: Johannes SixtNext: Johannes Sixt
Message 7 of 13 in “Documentation: update [section.subsection] to reflect what git does”
  1. Documentation: update [section.subsection] to reflect what git doesCarlos Martín Nieto, Oct 12, 2011
  2. Jeff KingOct 12, 2011
  3. Jeff KingOct 12, 2011
  4. Jeff KingOct 12, 2011
  5. 1/2 t1300: put git invocations inside test functionJeff King, Oct 12, 2011
  6. Johannes SixtOct 19, 2011
  7. Junio C HamanoOct 19, 2011
  8. t1300: attempting to remove a non-existent .git/config is not an errorJohannes Sixt, Oct 19, 2011
  9. Jeff KingOct 19, 2011
  10. 2/2 t1300: test mixed-case variable retrievalJeff King, Oct 12, 2011
  11. Junio C HamanoOct 12, 2011
  12. Junio C HamanoOct 12, 2011
  13. Jeff KingOct 12, 2011

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.