]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-terminal: set TERM=vt100
authorJeff King <peff@peff.net>
Tue, 3 Oct 2017 13:39:34 +0000 (09:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Oct 2017 02:25:12 +0000 (11:25 +0900)
The point of the test-terminal script is to simulate in the
test scripts an environment where output is going to a real
terminal.

But since test-lib.sh also sets TERM=dumb, the simulation
isn't very realistic. The color code will skip auto-coloring
for TERM=dumb, leading to us liberally sprinkling

  test_terminal env TERM=vt100 git ...

through the test suite to convince the tests to actually
generate colors. Let's set TERM for programs run under
test_terminal, which is one less thing for test-writers to
remember.

In most cases the callers can be simplified, but note there
is one interesting case in t4202. It uses test_terminal to
check the auto-enabling of --decorate, but the expected
output _doesn't_ contain colors (because TERM=dumb
suppresses them). Using TERM=vt100 is closer to what the
real world looks like; adjust the expected output to match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3203-branch-output.sh
t/t4202-log.sh
t/t6006-rev-list-format.sh
t/t6300-for-each-ref.sh
t/t7004-tag.sh
t/t7006-pager.sh
t/test-terminal.perl

index d2aec0f38b7913b27687b332029dc78be59bc182..86286f263dd6d0b0e4b1de1a64f6dc0183d37d27 100755 (executable)
@@ -253,7 +253,7 @@ test_expect_success '%(color) omitted without tty' '
 '
 
 test_expect_success TTY '%(color) present with tty' '
-       test_terminal env TERM=vt100 git branch $color_args >actual.raw &&
+       test_terminal git branch $color_args >actual.raw &&
        test_decode_color <actual.raw >actual &&
        test_cmp expect.color actual
 '
index 3f3531f0a49be39e29b20a36a55f0d27f04b4fc8..62f9d94fa3c25eabe484422c9238a1c6d0de1712 100755 (executable)
@@ -750,7 +750,7 @@ test_expect_success 'log.decorate config parsing' '
 '
 
 test_expect_success TTY 'log output on a TTY' '
-       git log --oneline --decorate >expect.short &&
+       git log --color --oneline --decorate >expect.short &&
 
        test_terminal git log --oneline >actual &&
        test_cmp expect.short actual
index b326d550f3e281e4b19ab669b95f08e8c63bf555..98be78b4a2123cad7e16911ae2eedff5695ba3d3 100755 (executable)
@@ -229,8 +229,7 @@ do
        '
 
        test_expect_success TTY "$desc respects --color=auto (stdout is tty)" '
-               test_terminal env TERM=vt100 \
-                       git log --format=$color -1 --color=auto >actual &&
+               test_terminal git log --format=$color -1 --color=auto >actual &&
                has_color actual
        '
 
index 2274a4b73310bfbc90886e0179a1cb12d9b6f3ed..d6bffe627347e34c012b2c996b3dd7a8573b6705 100755 (executable)
@@ -425,8 +425,7 @@ test_expect_success 'set up color tests' '
 '
 
 test_expect_success TTY '%(color) shows color with a tty' '
-       test_terminal env TERM=vt100 \
-               git for-each-ref --format="$color_format" >actual.raw &&
+       test_terminal git for-each-ref --format="$color_format" >actual.raw &&
        test_decode_color <actual.raw >actual &&
        test_cmp expected.color actual
 '
index dd5ba450ee4b33801dc39d0b57e4c4b08c1dfd62..6dc44478f9afd30939959371d79f5aaf620c5a55 100755 (executable)
@@ -1914,7 +1914,7 @@ test_expect_success '%(color) omitted without tty' '
 '
 
 test_expect_success TTY '%(color) present with tty' '
-       test_terminal env TERM=vt100 git tag $color_args >actual.raw &&
+       test_terminal git tag $color_args >actual.raw &&
        test_decode_color <actual.raw >actual &&
        test_cmp expect.color actual
 '
index 20b4d83c281e2fde8812f309bdebef012c6ecb74..20caa3f0956adced544058933497ba868de3c297 100755 (executable)
@@ -159,7 +159,7 @@ test_expect_success 'no color when stdout is a regular file' '
 test_expect_success TTY 'color when writing to a pager' '
        rm -f paginated.out &&
        test_config color.ui auto &&
-       test_terminal env TERM=vt100 git log &&
+       test_terminal git log &&
        colorful paginated.out
 '
 
@@ -167,7 +167,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
        rm -f paginated.out &&
        test_config color.ui auto &&
        test_config color.pager false &&
-       test_terminal env TERM=vt100 git log &&
+       test_terminal git log &&
        ! colorful paginated.out
 '
 
@@ -186,7 +186,7 @@ test_expect_success 'color when writing to a file intended for a pager' '
 test_expect_success TTY 'colors are sent to pager for external commands' '
        test_config alias.externallog "!git log" &&
        test_config color.ui auto &&
-       test_terminal env TERM=vt100 git -p externallog &&
+       test_terminal git -p externallog &&
        colorful paginated.out
 '
 
index 96b6a03e1c93c9ab6df356c2aad02514232f76ea..46bf6184798442560ad3ae7f68a7972680c5f8eb 100755 (executable)
@@ -80,6 +80,7 @@ sub copy_stdio {
 if ($#ARGV < 1) {
        die "usage: test-terminal program args";
 }
+$ENV{TERM} = 'vt100';
 my $master_in = new IO::Pty;
 my $master_out = new IO::Pty;
 my $master_err = new IO::Pty;