core.whitespace: add test for diff whitespace error highlighting
This tests seletive enabling/disabling of whitespace error highlighting done by colored diff output. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 2, 2007 at 17:46 UTC
49e703afda0e4e67050fcc8e05b175987c83391c
1 file changed
+76
t/t4019-diff-wserror.sh
new
+76
@@ -0,0 +1,76 @@
1
+#!/bin/sh
2
+
3
+test_description='diff whitespace error detection'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success setup '
8
+
9
+ git config diff.color.whitespace "blue reverse" &&
10
+ >F &&
11
+ git add F &&
12
+ echo " Eight SP indent" >>F &&
13
+ echo " HT and SP indent" >>F &&
14
+ echo "With trailing SP " >>F &&
15
+ echo "No problem" >>F
16
+
17
+'
18
+
19
+blue_grep='7;34m' ;# ESC [ 7 ; 3 4 m
20
+
21
+test_expect_success default '
22
+
23
+ git diff --color >output
24
+ grep "$blue_grep" output >error
25
+ grep -v "$blue_grep" output >normal
26
+
27
+ grep Eight normal >/dev/null &&
28
+ grep HT error >/dev/null &&
29
+ grep With error >/dev/null &&
30
+ grep No normal >/dev/null
31
+
32
+'
33
+
34
+test_expect_success 'without -trail' '
35
+
36
+ git config core.whitespace -trail
37
+ git diff --color >output
38
+ grep "$blue_grep" output >error
39
+ grep -v "$blue_grep" output >normal
40
+
41
+ grep Eight normal >/dev/null &&
42
+ grep HT error >/dev/null &&
43
+ grep With normal >/dev/null &&
44
+ grep No normal >/dev/null
45
+
46
+'
47
+
48
+test_expect_success 'without -space' '
49
+
50
+ git config core.whitespace -space
51
+ git diff --color >output
52
+ grep "$blue_grep" output >error
53
+ grep -v "$blue_grep" output >normal
54
+
55
+ grep Eight normal >/dev/null &&
56
+ grep HT normal >/dev/null &&
57
+ grep With error >/dev/null &&
58
+ grep No normal >/dev/null
59
+
60
+'
61
+
62
+test_expect_success 'with indent-non-tab only' '
63
+
64
+ git config core.whitespace indent,-trailing,-space
65
+ git diff --color >output
66
+ grep "$blue_grep" output >error
67
+ grep -v "$blue_grep" output >normal
68
+
69
+ grep Eight error >/dev/null &&
70
+ grep HT normal >/dev/null &&
71
+ grep With normal >/dev/null &&
72
+ grep No normal >/dev/null
73
+
74
+'
75
+
76
+test_done