[PATCH] test: skip test with COLUMNS=1 under mksh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mksh does not allow $COLUMNS to be set below 12. Quoting mksh(1)
$COLUMNS is "always set, defaults to 80, unless the value as reported
by stty(1) is non-zero and sane enough". This applies also to setting
it directly for one command:

$ COLUMNS=30 python -c 'import os; print os.environ["COLUMNS"]'
30
$ COLUMNS=20 python -c 'import os; print os.environ["COLUMNS"]'
20
$ COLUMNS=10 python -c 'import os; print os.environ["COLUMNS"]'
98

Let's test if we can set COLUMNS=1, and if not, skip the tests that
want to use that. A prereq is added, which is set if $COLUMNS can be
set.

In t9002-column.sh, file with expected output was shared between two
test cases, but set in the first one. Since the first test case can
now be skipped, setting up the expected output is moved outside of the
test case.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@xxxxxxxxx>
---

This fixes problems under /bin/sh=mksh in two newly added test files:
t4052 and t9002. I think that doing it with a prereq is fairly
minimalistic, and the output looks nice.

 t/t4052-stat-output.sh |    6 ++++--
 t/t9002-column.sh      |    5 +++--
 t/test-lib.sh          |    1 +
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index ced32db..ddd9497 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -292,7 +292,8 @@ cat >expect1-graph <<'EOF'
 EOF
 while read verb expect cmd args
 do
-	test_expect_success "$cmd $verb prefix greater than COLUMNS (big change)" '
+	test_expect_success COLUMNS_CAN_BE_1 \
+		"$cmd $verb prefix greater than COLUMNS (big change)" '
 		COLUMNS=1 git $cmd $args >output
 		grep " | " output >actual &&
 		test_cmp "$expect" actual
@@ -300,7 +301,8 @@ do
 
 	test "$cmd" != diff || continue
 
-	test_expect_success "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
+	test_expect_success COLUMNS_CAN_BE_1 \
+		"$cmd --graph $verb prefix greater than COLUMNS (big change)" '
 		COLUMNS=1 git $cmd $args --graph >output
 		grep " | " output >actual &&
 		test_cmp "$expect-graph" actual
diff --git a/t/t9002-column.sh b/t/t9002-column.sh
index c7d7a65..8998352 100755
--- a/t/t9002-column.sh
+++ b/t/t9002-column.sh
@@ -50,8 +50,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'COLUMNS = 1' '
-	cat >expected <<\EOF &&
+cat >expected <<\EOF
 one
 two
 three
@@ -64,6 +63,8 @@ nine
 ten
 eleven
 EOF
+
+test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' '
 	COLUMNS=1 git column --mode=column <lista >actual &&
 	test_cmp expected actual
 '
diff --git a/t/test-lib.sh b/t/test-lib.sh
index b7d7100..9e2b711 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -615,6 +615,7 @@ case $(uname -s) in
 	;;
 esac
 
+( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 test -n "$USE_LIBPCRE" && test_set_prereq LIBPCRE
-- 
1.7.10.433.g48a19

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]