git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>
To: Kacper Kornet <draenog@pld-linux.org>,
	git@vger.kernel.org, gitster@pobox.com
Cc: "Lucian Poston" <lucian.poston@gmail.com>,
	"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>
Subject: [PATCH] test: skip test with COLUMNS=1 under mksh
Date: Fri, 27 Apr 2012 11:25:25 +0200	[thread overview]
Message-ID: <1335518725-19728-1-git-send-email-zbyszek@in.waw.pl> (raw)
In-Reply-To: <20120426223422.GC22261@camk.edu.pl>

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@in.waw.pl>
---

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

  reply	other threads:[~2012-04-27  9:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18  2:29 [PATCH v4 1/4] t4052: test --stat output with --graph Lucian Poston
2012-04-18  2:29 ` [PATCH v4 2/4] Adjust stat width calculations to take --graph output into account Lucian Poston
2012-04-18  2:29 ` [PATCH v4 3/4] t4052: Test diff-stat output with minimum columns Lucian Poston
2012-04-18 20:15   ` Junio C Hamano
2012-04-18 21:19     ` Lucian Poston
2012-04-18 21:09   ` Lucian Poston
2012-04-26 22:34     ` Kacper Kornet
2012-04-27  9:25       ` Zbigniew Jędrzejewski-Szmek [this message]
2012-04-27 16:08         ` [PATCH] test: skip test with COLUMNS=1 under mksh Junio C Hamano
2012-04-28 11:09           ` Zbigniew Jędrzejewski-Szmek
2012-04-27 16:21         ` Junio C Hamano
2012-04-27 22:35           ` Stefano Lattarini
2012-04-28 11:09             ` Zbigniew Jędrzejewski-Szmek
2012-04-29 21:28               ` Junio C Hamano
2012-04-18  2:29 ` [PATCH v4 4/4] Prevent graph_width of stat width from falling below min Lucian Poston
2012-04-18 21:12   ` Lucian Poston
2012-04-18  8:47 ` [PATCH v4 1/4] t4052: test --stat output with --graph Zbigniew Jędrzejewski-Szmek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335518725-19728-1-git-send-email-zbyszek@in.waw.pl \
    --to=zbyszek@in.waw.pl \
    --cc=draenog@pld-linux.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lucian.poston@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).