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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 3, 2017 at 09:43 UTC
01c94e9001d5e78be32c64728058428fdb2febb4
1 file changed
+21
-20
t/t7508-status.sh
+21
-20
@@ -6,6 +6,7 @@
6
test_description='git status'
7
8
. ./test-lib.sh
9
+. "$TEST_DIRECTORY"/lib-terminal.sh
10
11
test_expect_success 'status -h in broken repository' '
12
git config --global advice.statusuoption false &&
@@ -667,7 +668,7 @@ test_expect_success 'setup unique colors' '
668
669
'
670
670
-test_expect_success 'status with color.ui' '
671
+test_expect_success TTY 'status with color.ui' '
672
cat >expect <<\EOF &&
673
On branch <GREEN>master<RESET>
674
Your branch and '\''upstream'\'' have diverged,
@@ -694,14 +695,14 @@ Untracked files:
695
<BLUE>untracked<RESET>
696
697
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 &&
700
test_i18ncmp expect output
701
'
702
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 &&
706
test_i18ncmp expect output
707
'
708
@@ -714,19 +715,19 @@ cat >expect <<\EOF
715
<BLUE>??<RESET> untracked
716
EOF
717
717
-test_expect_success 'status -s with color.ui' '
718
+test_expect_success TTY 'status -s with color.ui' '
719
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 &&
722
test_cmp expect output
723
724
'
725
725
-test_expect_success 'status -s with color.status' '
726
+test_expect_success TTY 'status -s with color.status' '
727
728
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 &&
731
test_cmp expect output
732
733
'
@@ -741,9 +742,9 @@ cat >expect <<\EOF
742
<BLUE>??<RESET> untracked
743
EOF
744
744
-test_expect_success 'status -s -b with color.status' '
745
+test_expect_success TTY 'status -s -b with color.status' '
746
746
- git status -s -b | test_decode_color >output &&
747
+ test_terminal git status -s -b | test_decode_color >output &&
748
test_i18ncmp expect output
749
750
'
@@ -757,20 +758,20 @@ A dir2/added
758
?? untracked
759
EOF
760
760
-test_expect_success 'status --porcelain ignores color.ui' '
761
+test_expect_success TTY 'status --porcelain ignores color.ui' '
762
763
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 &&
766
test_cmp expect output
767
768
'
769
769
-test_expect_success 'status --porcelain ignores color.status' '
770
+test_expect_success TTY 'status --porcelain ignores color.status' '
771
772
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 &&
775
test_cmp expect output
776
777
'