Skip to content

Commit 01c94e9

Browse files
peffgitster
authored andcommitted
t7508: use test_terminal for color output
This script tests the output of status with various formats when color is enabled. It uses the "always" setting so that the output is valid even though we capture it in a file. Using test_terminal gives us a more realistic environment, and prepares us for the behavior of "always" changing. Arguably we are testing less than before, since "auto" is already the default, and we can no longer tell if the config is actually doing anything. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8552972 commit 01c94e9

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

t/t7508-status.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
test_description='git status'
77

88
. ./test-lib.sh
9+
. "$TEST_DIRECTORY"/lib-terminal.sh
910

1011
test_expect_success 'status -h in broken repository' '
1112
git config --global advice.statusuoption false &&
@@ -667,7 +668,7 @@ test_expect_success 'setup unique colors' '
667668
668669
'
669670

670-
test_expect_success 'status with color.ui' '
671+
test_expect_success TTY 'status with color.ui' '
671672
cat >expect <<\EOF &&
672673
On branch <GREEN>master<RESET>
673674
Your branch and '\''upstream'\'' have diverged,
@@ -694,14 +695,14 @@ Untracked files:
694695
<BLUE>untracked<RESET>
695696
696697
EOF
697-
test_config color.ui always &&
698-
git status | test_decode_color >output &&
698+
test_config color.ui auto &&
699+
test_terminal git status | test_decode_color >output &&
699700
test_i18ncmp expect output
700701
'
701702

702-
test_expect_success 'status with color.status' '
703-
test_config color.status always &&
704-
git status | test_decode_color >output &&
703+
test_expect_success TTY 'status with color.status' '
704+
test_config color.status auto &&
705+
test_terminal git status | test_decode_color >output &&
705706
test_i18ncmp expect output
706707
'
707708

@@ -714,19 +715,19 @@ cat >expect <<\EOF
714715
<BLUE>??<RESET> untracked
715716
EOF
716717

717-
test_expect_success 'status -s with color.ui' '
718+
test_expect_success TTY 'status -s with color.ui' '
718719
719-
git config color.ui always &&
720-
git status -s | test_decode_color >output &&
720+
git config color.ui auto &&
721+
test_terminal git status -s | test_decode_color >output &&
721722
test_cmp expect output
722723
723724
'
724725

725-
test_expect_success 'status -s with color.status' '
726+
test_expect_success TTY 'status -s with color.status' '
726727
727728
git config --unset color.ui &&
728-
git config color.status always &&
729-
git status -s | test_decode_color >output &&
729+
git config color.status auto &&
730+
test_terminal git status -s | test_decode_color >output &&
730731
test_cmp expect output
731732
732733
'
@@ -741,9 +742,9 @@ cat >expect <<\EOF
741742
<BLUE>??<RESET> untracked
742743
EOF
743744

744-
test_expect_success 'status -s -b with color.status' '
745+
test_expect_success TTY 'status -s -b with color.status' '
745746
746-
git status -s -b | test_decode_color >output &&
747+
test_terminal git status -s -b | test_decode_color >output &&
747748
test_i18ncmp expect output
748749
749750
'
@@ -757,20 +758,20 @@ A dir2/added
757758
?? untracked
758759
EOF
759760

760-
test_expect_success 'status --porcelain ignores color.ui' '
761+
test_expect_success TTY 'status --porcelain ignores color.ui' '
761762
762763
git config --unset color.status &&
763-
git config color.ui always &&
764-
git status --porcelain | test_decode_color >output &&
764+
git config color.ui auto &&
765+
test_terminal git status --porcelain | test_decode_color >output &&
765766
test_cmp expect output
766767
767768
'
768769

769-
test_expect_success 'status --porcelain ignores color.status' '
770+
test_expect_success TTY 'status --porcelain ignores color.status' '
770771
771772
git config --unset color.ui &&
772-
git config color.status always &&
773-
git status --porcelain | test_decode_color >output &&
773+
git config color.status auto &&
774+
test_terminal git status --porcelain | test_decode_color >output &&
774775
test_cmp expect output
775776
776777
'

0 commit comments

Comments
 (0)