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

Re: [PATCH 2/3] submodule tests: reset "trace.out" between "grep" invocations

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 31, 2022, 23:58 UTC
Message-ID
<Y2BhQHynNWkl6cbY@nand.local>
In-Reply-To
<221031.86pme86tcg.gmgdl@evledraar.gmail.com>
On Mon, Oct 31, 2022 at 01:50:07PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 22 quoted lines
> >>  	(
> >>  		cd downstream &&
> >>  		GIT_TRACE=$(pwd)/trace.out git fetch &&
> >>  		grep "1 tasks" trace.out &&
> >> +		>trace.out &&
> >> +
> >
> > I fail to see why these hunks are necessary. If we specify GIT_TRACE,
> > and don't have a test_must_fail around the execution, then why should we
> > feel obligated to clean up the trace.out after every execution?
>
> Because the trace file isn't clobbered by each git command that
> specifies GIT_TRACE, so these tests are basically doing:
>
> 	(echo foo; echo bar) >>trace &&
> 	grep foo trace &&
>
>         (echo bar) >>trace &&
> 	grep bar trace
>
> Now, it just so happens that the earlier command isn't echoing "bar" to
> the file, so this is currently working out.

Ah, nicely explained. This is new to me, since I thought the behavior of both GIT_TRACE and GIT_TRACE2 was to clobber the file.

Show 7 quoted lines
> But it's a bad pattern to be pretending as though you care about the
> last output (which was the intent of the test), when really what you're
> testing is the combined output of all preceding commands.
>
> This would also be a potenital landmine with "test_must_fail", just
> because the command failed we're not guaranteed to have written nothing
> to the log (and usually we'd get as far as to write something).
Yeah, both make sense, thanks.

Thanks, Taylor

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 9 of 11 in “tests: improve misc run-command, hook, submodule tests”
  1. 0/3 tests: improve misc run-command, hook, submodule testsÆvar Arnfjörð Bjarmason, Oct 29, 2022
  2. 1/3 hook tests: fix redirection logic error in 96e7225b310Ævar Arnfjörð Bjarmason, Oct 29, 2022
  3. Taylor BlauOct 29, 2022
  4. Ævar Arnfjörð BjarmasonOct 31, 2022
  5. Taylor BlauOct 31, 2022
  6. 2/3 submodule tests: reset "trace.out" between "grep" invocationsÆvar Arnfjörð Bjarmason, Oct 29, 2022
  7. Taylor BlauOct 29, 2022
  8. Ævar Arnfjörð BjarmasonOct 31, 2022
  9. Taylor BlauOct 31, 2022
  10. 3/3 run-command tests: test stdout of run_command_parallel()Ævar Arnfjörð Bjarmason, Oct 29, 2022
  11. Taylor BlauOct 29, 2022

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.