Skip to content

Commit 0ad782f

Browse files
committed
t4015: separate common setup and per-test expectation
The last two tests in the script were to - set up color.diff.* slots - set up an expectation for a single test - run that test and check the result but split in a wrong way. It did the first two in the first test and the third one in the second test. The latter two belong to each other. This matters when you plan to add more of these tests that share the common coloring. While at it, make sure we use a color different from old, which is also red. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d55ef3e commit 0ad782f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -810,30 +810,31 @@ test_expect_success 'setup diff colors' '
810810
git config color.diff.old red &&
811811
git config color.diff.new green &&
812812
git config color.diff.commit yellow &&
813-
git config color.diff.whitespace "normal red" &&
813+
git config color.diff.whitespace blue &&
814814
815-
git config core.autocrlf false &&
815+
git config core.autocrlf false
816+
'
817+
818+
test_expect_success 'diff that introduces a line with only tabs' '
819+
git config core.whitespace blank-at-eol &&
820+
git reset --hard &&
821+
echo "test" >x &&
822+
git commit -m "initial" x &&
823+
echo "{NTN}" | tr "NT" "\n\t" >>x &&
824+
git -c color.diff=always diff | test_decode_color >current &&
816825
817-
cat >expected <<-\EOF
826+
cat >expected <<-\EOF &&
818827
<BOLD>diff --git a/x b/x<RESET>
819828
<BOLD>index 9daeafb..2874b91 100644<RESET>
820829
<BOLD>--- a/x<RESET>
821830
<BOLD>+++ b/x<RESET>
822831
<CYAN>@@ -1 +1,4 @@<RESET>
823832
test<RESET>
824833
<GREEN>+<RESET><GREEN>{<RESET>
825-
<GREEN>+<RESET><BRED> <RESET>
834+
<GREEN>+<RESET><BLUE> <RESET>
826835
<GREEN>+<RESET><GREEN>}<RESET>
827836
EOF
828-
'
829837
830-
test_expect_success 'diff that introduces a line with only tabs' '
831-
git config core.whitespace blank-at-eol &&
832-
git reset --hard &&
833-
echo "test" >x &&
834-
git commit -m "initial" x &&
835-
echo "{NTN}" | tr "NT" "\n\t" >>x &&
836-
git -c color.diff=always diff | test_decode_color >current &&
837838
test_cmp expected current
838839
'
839840

0 commit comments

Comments
 (0)