Skip to content

Commit 77d90d2

Browse files
authored
Merge pull request #5166 from grondo/COLUMNS-fix
testsuite: skip tests that expect COLUMNS to be inherited across calls to flux(1) when that isn't true
2 parents 1a25d9a + fe50aed commit 77d90d2

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

t/sharness.d/flux-sharness.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,23 @@ test_on_rank() {
292292
flux exec --rank=${ranks} "$@"
293293
}
294294

295+
# Note: Some versions of bash may cause the `flux` libtool wrapper script
296+
# to reset the COLUMNS shell variable even if it is explicitly set for
297+
# for testing purposes. This causes tests that check for output truncation
298+
# based on COLUMNS to erroneously fail. (Note: this only seems to be the
299+
# case when tests are run with --debug --verbose for unknown reasons.
300+
#
301+
# Add a script for tests that use COLUMNS to check if the variable will
302+
# be preserved across an invovation of flux(1) so they may set a prereq
303+
# and skip tests that might erroneous fail if COLUMNS is not preserved.
304+
#
305+
test_columns_variable_preserved() {
306+
local cols=$(COLUMNS=12 \
307+
flux python -c \
308+
"import shutil; print(shutil.get_terminal_size().columns)")
309+
test "$cols" = "12"
310+
}
311+
295312
# Export a shorter name for this test
296313
TEST_NAME=$SHARNESS_TEST_NAME
297314
export TEST_NAME

t/t1000-kvs.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,8 @@ test_expect_success 'kvs: ls -w40 adjusts output width to 40' '
681681
EOF
682682
test_cmp expected output
683683
'
684-
test_expect_success 'kvs: ls with COLUMNS=20 adjusts output width to 20' '
684+
test_columns_variable_preserved && test_set_prereq USE_COLUMNS
685+
test_expect_success USE_COLUMNS 'kvs: ls with COLUMNS=20 adjusts output width to 20' '
685686
flux kvs unlink -Rf $DIR &&
686687
${FLUX_BUILD_DIR}/t/kvs/dtree -p$DIR -h1 -w50 &&
687688
COLUMNS=20 flux kvs ls $DIR | wc -wl >output &&

t/t2803-flux-pstree.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ test_expect_success 'flux-pstree -a works' '
149149
EOF
150150
test_cmp ${name}.expected ${name}.output
151151
'
152-
test_expect_success 'flux-pstree truncates at COLUMNS' '
152+
test_columns_variable_preserved && test_set_prereq USE_COLUMNS
153+
test_expect_success USE_COLUMNS 'flux-pstree truncates at COLUMNS' '
153154
name="truncated" &&
154155
COLUMNS=16 flux pstree -a > ${name}.output &&
155156
test_debug "cat ${name}.output" &&

0 commit comments

Comments
 (0)