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

[PATCH v2] test-lib.sh: set COLUMNS=80 for --verbose repeatability

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 29, 2021, 11:29 UTC
Message-ID
<patch-1.1-bd2bd89a2b-20210629T112910Z-avarab@gmail.com>
In-Reply-To
<patch-1.1-765c2793122-20210624T101839Z-avarab@gmail.com>

Some tests will fail under --verbose because while we've unset COLUMNS since b1d645b58ac (tests: unset COLUMNS inherited from environment, 2012-03-27), we also look for the columns with an ioctl(.., TIOCGWINSZ, ...) on some platforms. By setting COLUMNS again we preempt the TIOCGWINSZ lookup in pager.c's term_columns(), it'll take COLUMNS over TIOCGWINSZ,

This fixes t0500-progress-display.sh., which broke because of a combination of the this issue and the progress output reacting to the column width since 545dc345ebd (progress: break too long progress bar lines, 2019-04-12). The t5324-split-commit-graph.sh fails in a similar manner due to progress output, see [1] for details.

The issue is not specific to progress.c, the diff code also checks COLUMNS and some of its tests can be made to fail in a similar manner[2], anything that invokes a pager is potentially affected.

See ea77e675e56 (Make "git help" react to window size correctly, 2005-12-18) and ad6c3739a33 (pager: find out the terminal width before spawning the pager, 2012-02-12) for how the TIOCGWINSZ code ended up in pager.c

1. http://lore.kernel.org/git/20210624051253.GG6312@szeder.dev
2. https://lore.kernel.org/git/20210627074419.GH6312@szeder.dev/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
No code changes since v1, just the suggested commit message change.
Range-diff against v1:
1:  765c279312 ! 1:  bd2bd89a2b test-lib.sh: set COLUMNS=80 for --verbose repeatability
    @@ Commit message
         preempt the TIOCGWINSZ lookup in pager.c's term_columns(), it'll take
         COLUMNS over TIOCGWINSZ,
     
    -    This fixes the t0500-progress-display.sh test when run as:
    +    This fixes t0500-progress-display.sh., which broke because of a
    +    combination of the this issue and the progress output reacting to the
    +    column width since 545dc345ebd (progress: break too long progress bar
    +    lines, 2019-04-12). The t5324-split-commit-graph.sh fails in a similar
    +    manner due to progress output, see [1] for details.
     
    -        ./t0500-progress-display.sh --verbose
    -
    -    It broke because of a combination of the this issue and the progress
    -    output reacting to the column width since 545dc345ebd (progress: break
    -    too long progress bar lines, 2019-04-12). The
    -    t5324-split-commit-graph.sh fails in a similar manner due to progress
    -    output, see [1] for details.
    -
    -    A more narrow fix here would be to only do this in the --verbose mode,
    -    but there's no harm in setting this for everything. If we're not
    -    connected to a TTY the COLUMNS setting won't matter.
    +    The issue is not specific to progress.c, the diff code also checks
    +    COLUMNS and some of its tests can be made to fail in a similar
    +    manner[2], anything that invokes a pager is potentially affected.
     
         See ea77e675e56 (Make "git help" react to window size correctly,
         2005-12-18) and ad6c3739a33 (pager: find out the terminal width before
    @@ Commit message
         in pager.c
     
         1. http://lore.kernel.org/git/20210624051253.GG6312@szeder.dev
    +    2. https://lore.kernel.org/git/20210627074419.GH6312@szeder.dev/
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
 t/test-lib.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 54938c6427..1a6ca772d6 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -406,14 +406,15 @@ LANG=C
 LC_ALL=C
 PAGER=cat
 TZ=UTC
-export LANG LC_ALL PAGER TZ
+COLUMNS=80
+export LANG LC_ALL PAGER TZ COLUMNS
 EDITOR=:
 
 # A call to "unset" with no arguments causes at least Solaris 10
 # /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets
 # deriving from the command substitution clustered with the other
 # ones.
-unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
+unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
 		TRACE
-- 
2.32.0.615.g90fb4d7369
Previous: Junio C Hamano
Message 10 of 10 in “progress.c tests: fix breakage with COLUMNS != 80”
  1. progress.c tests: fix breakage with COLUMNS != 80Ævar Arnfjörð Bjarmason, Jun 21, 2021
  2. Jeff KingJun 23, 2021
  3. SZEDER GáborJun 24, 2021
  4. Jeff KingJun 24, 2021
  5. Philip OakleyJun 24, 2021
  6. test-lib.sh: set COLUMNS=80 for --verbose repeatabilityÆvar Arnfjörð Bjarmason, Jun 24, 2021
  7. Jeff KingJun 24, 2021
  8. SZEDER GáborJun 27, 2021
  9. Junio C HamanoJun 29, 2021
  10. test-lib.sh: set COLUMNS=80 for --verbose repeatabilityÆvar Arnfjörð Bjarmason, Jun 29, 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.