t3701: use test-terminal to collect color output

When testing whether "add -p" can generate colors, we set color.ui to "always". This isn't a very good test, as in the real-world a user typically has "auto" coupled with stdout going to a terminal (and it's plausible that this could mask a real bug in add--interactive if we depend on plumbing's isatty check). Let's switch to test_terminal, which gives us a more realistic environment. This also prepare us for future changes to the "always" color option. 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:42 UTC 8552972b133ee5147f3af11ab21cf4b1d04e97e5
1 file changed +3 -5
t/t3701-add-interactive.sh
+3 -5
@@ -2,6 +2,7 @@
2
3 test_description='add -i basic tests'
4 . ./test-lib.sh
5 +. "$TEST_DIRECTORY"/lib-terminal.sh
6
7 if ! test_have_prereq PERL
8 then
@@ -380,14 +381,11 @@ test_expect_success 'patch mode ignores unmerged entries' '
381 test_cmp expected diff
382 '
383
383 -test_expect_success 'diffs can be colorized' '
384 +test_expect_success TTY 'diffs can be colorized' '
385 git reset --hard &&
386
386 - # force color even though the test script has no terminal
387 - test_config color.ui always &&
388 -
387 echo content >test &&
390 - printf y | git add -p >output 2>&1 &&
388 + printf y | test_terminal git add -p >output 2>&1 &&
389
390 # We do not want to depend on the exact coloring scheme
391 # git uses for diffs, so just check that we saw some kind of color.