Thread (6 messages) flat view 6 messages, 4 authors, 2021-08-07

Re: [PATCH v2] test: fix for COLUMNS and bash 5

From: ZheNing Hu <hidden>
Date: 2021-08-07 01:36:23

Felipe Contreras [off-list ref] 于2021年8月7日周六 上午12:44写道:
quoted hunk ↗ jump to hunk
Since c49a177bec (test-lib.sh: set COLUMNS=80 for --verbose
repeatability, 2021-06-29) multiple tests have been failing when using
bash 5 because checkwinsize is enabled by default, therefore COLUMNS is
reset using TIOCGWINSZ even for non-interactive shells.

It's debatable whether or not bash should even be doing that, but for
now we can avoid this undesirable behavior by disabling this option.

Reported-by: Fabian Stelzer <redacted>
Signed-off-by: Felipe Contreras <redacted>
---

Since v1 moved the code before setting COLUMNS as SZEDER Gábor suggested
and mention checkwinsize could be set before bash 5 as Ævar Arnfjörð
Bjarmason mentioned.

Range-diff against v1:
1:  40273074de < -:  ---------- test: fix for COLUMNS and bash 5
-:  ---------- > 1:  9f8c3ffa6a test: fix for COLUMNS and bash 5

 t/test-lib.sh | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index db61081d6b..6b1015a5af 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -409,6 +409,12 @@ then
        verbose=t
 fi

+# In bash if checkwinsize is enabled the COLUMNS variable is updated every time
+# an external command completes, even for non-interactive shells. Since bash 5.0
+# this is enabled by default.
+# Disable that since we are aiming for reproducibility.
+test -n "$BASH_VERSION" && shopt -u checkwinsize 2>/dev/null
+
 # For repeatability, reset the environment to known value.
 # TERM is sanitized below, after saving color control sequences.
 LANG=C
--
2.32.0.40.gb9b36f9b52
This can work on Arch-Linux. LGTM.

Thanks.
--
ZheNing Hu
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help