Skip to content

Commit e433749

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 11b087a commit e433749

File tree

7 files changed

+9
-10
lines changed

7 files changed

+9
-10
lines changed

t/t3203-branch-output.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ test_expect_success '%(color) omitted without tty' '
253253
'
254254

255255
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 &&
257257
test_decode_color <actual.raw >actual &&
258258
test_cmp expect.color actual
259259
'

t/t4202-log.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ test_expect_success 'log.decorate config parsing' '
750750
'
751751

752752
test_expect_success TTY 'log output on a TTY' '
753-
git log --oneline --decorate >expect.short &&
753+
git log --color --oneline --decorate >expect.short &&
754754
755755
test_terminal git log --oneline >actual &&
756756
test_cmp expect.short actual

t/t6006-rev-list-format.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ do
229229
'
230230

231231
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 &&
234233
has_color actual
235234
'
236235

t/t6300-for-each-ref.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ test_expect_success 'set up color tests' '
425425
'
426426

427427
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 &&
430429
test_decode_color <actual.raw >actual &&
431430
test_cmp expected.color actual
432431
'

t/t7004-tag.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ test_expect_success '%(color) omitted without tty' '
19141914
'
19151915

19161916
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 &&
19181918
test_decode_color <actual.raw >actual &&
19191919
test_cmp expect.color actual
19201920
'

t/t7006-pager.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ test_expect_success 'no color when stdout is a regular file' '
159159
test_expect_success TTY 'color when writing to a pager' '
160160
rm -f paginated.out &&
161161
test_config color.ui auto &&
162-
test_terminal env TERM=vt100 git log &&
162+
test_terminal git log &&
163163
colorful paginated.out
164164
'
165165

166166
test_expect_success TTY 'colors are suppressed by color.pager' '
167167
rm -f paginated.out &&
168168
test_config color.ui auto &&
169169
test_config color.pager false &&
170-
test_terminal env TERM=vt100 git log &&
170+
test_terminal git log &&
171171
! colorful paginated.out
172172
'
173173

@@ -186,7 +186,7 @@ test_expect_success 'color when writing to a file intended for a pager' '
186186
test_expect_success TTY 'colors are sent to pager for external commands' '
187187
test_config alias.externallog "!git log" &&
188188
test_config color.ui auto &&
189-
test_terminal env TERM=vt100 git -p externallog &&
189+
test_terminal git -p externallog &&
190190
colorful paginated.out
191191
'
192192

t/test-terminal.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ sub copy_stdio {
8080
if ($#ARGV < 1) {
8181
die "usage: test-terminal program args";
8282
}
83+
$ENV{TERM} = 'vt100';
8384
my $master_in = new IO::Pty;
8485
my $master_out = new IO::Pty;
8586
my $master_err = new IO::Pty;

0 commit comments

Comments
 (0)