t4015: split out the "setup" part of ws-error-highlight test
We'd want to run this same set of test twice, once with the option and another time with an equivalent configuration setting. Split out the step that prepares the test data and expected output and move the test for the command line option into a separate test. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Oct 4, 2016 at 15:21 UTC
f3f5c7f5201ef71e62cea41a8b692cace2dcf579
1 file changed
+21
-18
t/t4015-diff-whitespace.sh
+21
-18
@@ -869,7 +869,8 @@ test_expect_success 'diff that introduces and removes ws breakages' '
869
test_cmp expected current
870
'
871
872
-test_expect_success 'the same with --ws-error-highlight' '
872
+test_expect_success 'ws-error-highlight test setup' '
873
+
874
git reset --hard &&
875
{
876
echo "0. blank-at-eol " &&
@@ -882,10 +883,7 @@ test_expect_success 'the same with --ws-error-highlight' '
883
echo "2. and a new line "
884
} >x &&
885
885
- git -c color.diff=always diff --ws-error-highlight=default,old |
886
- test_decode_color >current &&
887
-
888
- cat >expected <<-\EOF &&
886
+ cat >expect.default-old <<-\EOF &&
887
<BOLD>diff --git a/x b/x<RESET>
888
<BOLD>index d0233a2..700886e 100644<RESET>
889
<BOLD>--- a/x<RESET>
@@ -897,12 +895,7 @@ test_expect_success 'the same with --ws-error-highlight' '
895
<GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
896
EOF
897
900
- test_cmp expected current &&
901
-
902
- git -c color.diff=always diff --ws-error-highlight=all |
903
- test_decode_color >current &&
904
-
905
- cat >expected <<-\EOF &&
898
+ cat >expect.all <<-\EOF &&
899
<BOLD>diff --git a/x b/x<RESET>
900
<BOLD>index d0233a2..700886e 100644<RESET>
901
<BOLD>--- a/x<RESET>
@@ -914,12 +907,7 @@ test_expect_success 'the same with --ws-error-highlight' '
907
<GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
908
EOF
909
917
- test_cmp expected current &&
918
-
919
- git -c color.diff=always diff --ws-error-highlight=none |
920
- test_decode_color >current &&
921
-
922
- cat >expected <<-\EOF &&
910
+ cat >expect.none <<-\EOF
911
<BOLD>diff --git a/x b/x<RESET>
912
<BOLD>index d0233a2..700886e 100644<RESET>
913
<BOLD>--- a/x<RESET>
@@ -931,7 +919,22 @@ test_expect_success 'the same with --ws-error-highlight' '
919
<GREEN>+2. and a new line <RESET>
920
EOF
921
934
- test_cmp expected current
922
+'
923
+
924
+test_expect_success 'test --ws-error-highlight option' '
925
+
926
+ git -c color.diff=always diff --ws-error-highlight=default,old |
927
+ test_decode_color >current &&
928
+ test_cmp expect.default-old current &&
929
+
930
+ git -c color.diff=always diff --ws-error-highlight=all |
931
+ test_decode_color >current &&
932
+ test_cmp expect.all current &&
933
+
934
+ git -c color.diff=always diff --ws-error-highlight=none |
935
+ test_decode_color >current &&
936
+ test_cmp expect.none current
937
+
938
'
939
940
test_done