test-terminal: set TERM=vt100

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>

Jeff King committed Oct 3, 2017 at 09:39 UTC e433749d86c55af27f762c862dbb06d1e108da13
7 files changed +9 -10
t/t3203-branch-output.sh
+1 -1
@@ -253,7 +253,7 @@ test_expect_success '%(color) omitted without tty' '
253 '
254
255 test_expect_success TTY '%(color) present with tty' '
256 - test_terminal env TERM=vt100 git branch $color_args >actual.raw &&
256 + test_terminal git branch $color_args >actual.raw &&
257 test_decode_color <actual.raw >actual &&
258 test_cmp expect.color actual
259 '
t/t4202-log.sh
+1 -1
@@ -750,7 +750,7 @@ test_expect_success 'log.decorate config parsing' '
750 '
751
752 test_expect_success TTY 'log output on a TTY' '
753 - git log --oneline --decorate >expect.short &&
753 + git log --color --oneline --decorate >expect.short &&
754
755 test_terminal git log --oneline >actual &&
756 test_cmp expect.short actual
t/t6006-rev-list-format.sh
+1 -2
@@ -229,8 +229,7 @@ do
229 '
230
231 test_expect_success TTY "$desc respects --color=auto (stdout is tty)" '
232 - test_terminal env TERM=vt100 \
233 - git log --format=$color -1 --color=auto >actual &&
232 + test_terminal git log --format=$color -1 --color=auto >actual &&
233 has_color actual
234 '
235
t/t6300-for-each-ref.sh
+1 -2
@@ -425,8 +425,7 @@ test_expect_success 'set up color tests' '
425 '
426
427 test_expect_success TTY '%(color) shows color with a tty' '
428 - test_terminal env TERM=vt100 \
429 - git for-each-ref --format="$color_format" >actual.raw &&
428 + test_terminal git for-each-ref --format="$color_format" >actual.raw &&
429 test_decode_color <actual.raw >actual &&
430 test_cmp expected.color actual
431 '
t/t7004-tag.sh
+1 -1
@@ -1914,7 +1914,7 @@ test_expect_success '%(color) omitted without tty' '
1914 '
1915
1916 test_expect_success TTY '%(color) present with tty' '
1917 - test_terminal env TERM=vt100 git tag $color_args >actual.raw &&
1917 + test_terminal git tag $color_args >actual.raw &&
1918 test_decode_color <actual.raw >actual &&
1919 test_cmp expect.color actual
1920 '
t/t7006-pager.sh
+3 -3
@@ -159,7 +159,7 @@ test_expect_success 'no color when stdout is a regular file' '
159 test_expect_success TTY 'color when writing to a pager' '
160 rm -f paginated.out &&
161 test_config color.ui auto &&
162 - test_terminal env TERM=vt100 git log &&
162 + test_terminal git log &&
163 colorful paginated.out
164 '
165
@@ -167,7 +167,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
167 rm -f paginated.out &&
168 test_config color.ui auto &&
169 test_config color.pager false &&
170 - test_terminal env TERM=vt100 git log &&
170 + test_terminal git log &&
171 ! colorful paginated.out
172 '
173
@@ -186,7 +186,7 @@ test_expect_success 'color when writing to a file intended for a pager' '
186 test_expect_success TTY 'colors are sent to pager for external commands' '
187 test_config alias.externallog "!git log" &&
188 test_config color.ui auto &&
189 - test_terminal env TERM=vt100 git -p externallog &&
189 + test_terminal git -p externallog &&
190 colorful paginated.out
191 '
192
t/test-terminal.perl
+1
@@ -80,6 +80,7 @@ sub copy_stdio {
80 if ($#ARGV < 1) {
81 die "usage: test-terminal program args";
82 }
83 +$ENV{TERM} = 'vt100';
84 my $master_in = new IO::Pty;
85 my $master_out = new IO::Pty;
86 my $master_err = new IO::Pty;