Skip to content

Commit c6bc53a

Browse files
peffgitster
authored andcommitted
diff-highlight: test color config
We added configurable colors long ago in bca45fb (diff-highlight: allow configurable colors, 2014-11-20), but never actually tested it. Since we'll be touching the color code in a moment, this is a good time to beef up the tests. Note that we cover both the highlight/reset style used by the default colors, as well as the normal/highlight style added by that commit (which was previously totally untested). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e57daf9 commit c6bc53a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

contrib/diff-highlight/t/t9400-diff-highlight.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,32 @@ test_expect_success 'highlight diff that removes final newline' '
350350
EOF
351351
'
352352

353+
test_expect_success 'configure set/reset colors' '
354+
test_config color.diff-highlight.oldhighlight bold &&
355+
test_config color.diff-highlight.oldreset nobold &&
356+
test_config color.diff-highlight.newhighlight italic &&
357+
test_config color.diff-highlight.newreset noitalic &&
358+
echo "prefix a suffix" >a &&
359+
echo "prefix b suffix" >b &&
360+
dh_test a b <<-\EOF
361+
@@ -1 +1 @@
362+
-prefix <BOLD>a<NORMAL_INTENSITY> suffix
363+
+prefix <ITALIC>b<NOITALIC> suffix
364+
EOF
365+
'
366+
367+
test_expect_success 'configure normal/highlight colors' '
368+
test_config color.diff-highlight.oldnormal red &&
369+
test_config color.diff-highlight.oldhighlight magenta &&
370+
test_config color.diff-highlight.newnormal green &&
371+
test_config color.diff-highlight.newhighlight yellow &&
372+
echo "prefix a suffix" >a &&
373+
echo "prefix b suffix" >b &&
374+
dh_test a b <<-\EOF
375+
@@ -1 +1 @@
376+
<RED>-prefix <RESET><MAGENTA>a<RESET><RED> suffix<RESET>
377+
<GREEN>+prefix <RESET><YELLOW>b<RESET><GREEN> suffix<RESET>
378+
EOF
379+
'
380+
353381
test_done

0 commit comments

Comments
 (0)