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 <gitster@pobox.com>
Junio C Hamano committed
May 26, 2015 at 11:43 UTC
0ad782f2406fa13f626653a001b5f01a9f3fa40f
1 file changed
+13
-12
t/t4015-diff-whitespace.sh
+13
-12
@@ -810,11 +810,20 @@ test_expect_success 'setup diff colors' '
810
git config color.diff.old red &&
811
git config color.diff.new green &&
812
git config color.diff.commit yellow &&
813
- git config color.diff.whitespace "normal red" &&
813
+ git config color.diff.whitespace blue &&
814
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 &&
825
817
- cat >expected <<-\EOF
826
+ cat >expected <<-\EOF &&
827
<BOLD>diff --git a/x b/x<RESET>
828
<BOLD>index 9daeafb..2874b91 100644<RESET>
829
<BOLD>--- a/x<RESET>
@@ -822,18 +831,10 @@ test_expect_success 'setup diff colors' '
831
<CYAN>@@ -1 +1,4 @@<RESET>
832
test<RESET>
833
<GREEN>+<RESET><GREEN>{<RESET>
825
- <GREEN>+<RESET><BRED> <RESET>
834
+ <GREEN>+<RESET><BLUE> <RESET>
835
<GREEN>+<RESET><GREEN>}<RESET>
836
EOF
828
-'
837
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 &&
838
test_cmp expected current
839
'
840