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

Re: [PATCH] test-lib.sh: use GIT_TEST_COLUMNS over COLUMNS

From
Jeff King <peff@peff.net>
Date
Jul 27, 2021, 17:38 UTC
Message-ID
<YQBEhj/Y6m0pqOth@coredump.intra.peff.net>
In-Reply-To
<patch-1.1-f81f3911d5-20210726T235452Z-avarab@gmail.com>
On Tue, Jul 27, 2021 at 01:57:09AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 24 quoted lines
> In my c49a177beca (test-lib.sh: set COLUMNS=80 for --verbose
> repeatability, 2021-06-29) the test suite started breaking on recent
> versions of bash.
> 
> This is because it sets "shopt -s checkwinsize" starting with version
> 5.0, furthermore it started setting COLUMNS under "shopt -s
> checkwinsize" for non-interactive use around version 4.3.
> 
> A narrow fix for that issue would be to add this just above our
> setting of COLUMNS in test-lib.sh:
> 
> 	shopt -u checkwinsize >/dev/null 2>&1
> 
> But we'd then be at the mercy of the next shell or terminal that wants
> to be clever about COLUMNS.
> 
> Let's instead solve this more thoroughly. We'll now take
> GIT_TEST_COLUMNS over COLUMNS, and furthermore intentionally spoil the
> COLUMNS variable to break any tests that rely on it being set to a
> sane value.
> 
> If something breaks because we have a codepath that's not
> term_columns() checking COLUMNS we'd like to know about it, the narrow
> "shopt -u checkwinsize" fix won't give us that.

I guess people running with bash won't see the test breakage (because bash will quietly "fix" the COLUMNS setting). But enough people run with /bin/sh that we'll eventually notice.

> This approach does mean that any tests of ours that expected to test
> term_columns() behavior by setting COLUMNS will need to explicitly
> unset GIT_TEST_COLUMNS, or set it to the empty string. I'm doing the
> latter in all the tests changed here.

This is rather ugly, and I'm not in general a fan of adding more test-only code into the bowels of Git itself. But it may be the least bad solution.

The only alternative I could come up with is _not_ to set COLUMNS everywhere, but instead insist on each individual test manually doing "COLUMNS=80 git ...". Setting it as a one-shot seems to be reliable enough. The downside is just that various tests will need to do so. We already have quite a few that do, but I guess anything that uses the progress meter is now subject to it.

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 15 of 26 in “progress test failure on fedora34”
  1. Fabian StelzerJul 14, 2021
  2. Ævar Arnfjörð BjarmasonJul 14, 2021
  3. Alex HenrieJul 14, 2021
  4. Ævar Arnfjörð BjarmasonJul 18, 2021
  5. Jeff KingJul 19, 2021
  6. Alex HenrieJul 19, 2021
  7. Alex HenrieJul 19, 2021
  8. Felipe ContrerasJul 19, 2021
  9. Felipe ContrerasJul 19, 2021
  10. Alex HenrieJul 19, 2021
  11. Felipe ContrerasJul 20, 2021
  12. ZheNing HuJul 21, 2021
  13. Felipe ContrerasJul 21, 2021
  14. test-lib.sh: use GIT_TEST_COLUMNS over COLUMNSÆvar Arnfjörð Bjarmason, Jul 26, 2021
  15. Jeff KingJul 27, 2021
  16. Junio C HamanoJul 28, 2021
  17. 0/3 test-lib.sh: use GIT_TEST_COLUMNS over COLUMNSÆvar Arnfjörð Bjarmason, Aug 2, 2021
  18. 1/3 test-lib-functions.sh: rename test_must_fail_acceptable()Ævar Arnfjörð Bjarmason, Aug 2, 2021
  19. 3/3 test-lib.sh: use GIT_TEST_COLUMNS over COLUMNSÆvar Arnfjörð Bjarmason, Aug 2, 2021
  20. 2/3 test-lib-functions.sh: add a test_with_columns functionÆvar Arnfjörð Bjarmason, Aug 2, 2021
  21. SZEDER GáborAug 2, 2021
  22. Eric SunshineAug 2, 2021
  23. 0/3 test-lib.sh: use GIT_TEST_COLUMNS over COLUMNSÆvar Arnfjörð Bjarmason, Aug 4, 2021
  24. 1/3 test-lib-functions.sh: rename test_must_fail_acceptable()Ævar Arnfjörð Bjarmason, Aug 4, 2021
  25. 3/3 test-lib.sh: use GIT_TEST_COLUMNS over COLUMNSÆvar Arnfjörð Bjarmason, Aug 4, 2021
  26. 2/3 test-lib-functions.sh: add a test_with_columns functionÆvar Arnfjörð Bjarmason, Aug 4, 2021

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.