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

Side effects in Git's test suite, was Re: [PATCH] revert: optionally refer to commit in the "reference" format

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 30, 2022, 16:50 UTC
Message-ID
<nycvar.QRO.7.76.6.2205301840410.349@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqq35gzn9vk.fsf@gitster.g>
Hi Junio,
On Mon, 23 May 2022, Junio C Hamano wrote:
Show 25 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> >> +test_expect_success 'identification of reverted commit (reference)' '
> >> +	git checkout --detach to-ident &&
> >> +	git revert --reference --no-edit HEAD &&
> >> +	git cat-file commit HEAD >actual.raw &&
> >> +	grep "^This reverts " actual.raw >actual &&
> >> +	echo "This reverts commit $(git show -s --pretty=reference HEAD^)." >expect &&
> >> +	test_cmp expect actual
> >> +'
> >
> > If it was up to me, I would combine these three test cases, if only to
> > help the `--run=<single-number>` case (the latter two depend on the
> > side effect of the first one to create a `to-ident` tag).
>
> I wonder if our prereq infrastructure is lightweight and scalable enough
> so that we can easily add a support a pseudo-prerequisite PREVIOUS that
> lets us say
>
> 	test_expect_success PREVIOUS "identification ..." '
> 		...
> 	'
>
> to mean that this test requires the previous test has not been
> skipped.
In theory, this sounds good to me.

In practice, however, side effects are awful and make everything harder, from developing code to debugging to helping new contributors. I wish we would do away with them altogether and have something more akin to the before/after constructs known from e.g. TestNG (think `@BeforeTest` and `@BeforeClass`).

One option would be to mark `setup` steps completely differently, sort of imitating the prereq infrastructure instead of using `test_expect_success`. Kind of prereqs, but required to pass.

This could potentially allow us to randomize the order in which the test cases are run, to identify and fix (unintended) side effects.

A complication is that we have nothing in the way of `@AfterClass`, i.e. we do not have a way to, say, run an Apache instance for the lifecycle of a given test script _and tear it down at the end_.

Another, rather obvious complication is that we have 17 years of commit history introducing side effects left and right :laughing:

Ciao, Dscho

Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 11 of 20 in “revert: optionally refer to commit in the "reference" format”
  1. revert: optionally refer to commit in the "reference" formatJunio C Hamano, May 22, 2022
  2. Johannes SchindelinMay 23, 2022
  3. Junio C HamanoMay 23, 2022
  4. revert: optionally refer to commit in the "reference" formatJunio C Hamano, May 27, 2022
  5. Johannes SchindelinMay 30, 2022
  6. Phillip WoodMay 31, 2022
  7. Junio C HamanoJun 1, 2022
  8. Phillip WoodJun 1, 2022
  9. Ævar Arnfjörð BjarmasonJun 1, 2022
  10. Junio C HamanoJun 1, 2022
  11. Side effects in Git's test suite, was Re: [PATCH] revert: optionally refer to commit in the "reference" formatJohannes Schindelin, May 30, 2022
  12. Ævar Arnfjörð BjarmasonMay 31, 2022
  13. Ævar Arnfjörð BjarmasonMay 23, 2022
  14. Junio C HamanoMay 23, 2022
  15. Ævar Arnfjörð BjarmasonMay 24, 2022
  16. Junio C HamanoMay 24, 2022
  17. Phillip WoodMay 26, 2022
  18. Junio C HamanoMay 26, 2022
  19. René ScharfeJun 26, 2022
  20. Junio C HamanoJun 27, 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.