t4018: convert custom pattern test to the new infrastructure
For the test case "matches to end of line", extend the pattern by a few wildcards so that the pattern captures the "RIGHT" token, which is needed for verification, without mentioning it in the pattern. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Mar 21, 2014 at 22:07 UTC
f1b75fbaf1380e00668f775f27ba8dd52b78a081
4 files changed
+58
-24
t/t4018-diff-funcname.sh
+16
-24
@@ -30,12 +30,19 @@ public class Beer
30
EOF
31
sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java
32
33
-test_expect_funcname () {
34
- lang=${2-java}
35
- test_expect_code 1 git diff --no-index -U1 \
36
- "Beer.$lang" "Beer-correct.$lang" >diff &&
37
- grep "^@@.*@@ $1" diff
38
-}
33
+test_expect_success 'setup' '
34
+ # a non-trivial custom pattern
35
+ git config diff.custom1.funcname "!static
36
+!String
37
+[^ ].*s.*" &&
38
+
39
+ # a custom pattern which matches to end of line
40
+ git config diff.custom2.funcname "......Beer\$" &&
41
+
42
+ # alternation in pattern
43
+ git config diff.custom3.funcname "Beer$" &&
44
+ git config diff.custom3.xfuncname "^[ ]*((public|static).*)$"
45
+'
46
47
diffpatterns="
48
ada
@@ -53,6 +60,9 @@ diffpatterns="
60
python
61
ruby
62
tex
63
+ custom1
64
+ custom2
65
+ custom3
66
"
67
68
for p in $diffpatterns
@@ -79,30 +89,12 @@ test_expect_success 'set up .gitattributes declaring drivers to test' '
89
EOF
90
'
91
82
-test_expect_success 'custom pattern' '
83
- test_config diff.java.funcname "!static
84
-!String
85
-[^ ].*s.*" &&
86
- test_expect_funcname "int special;\$"
87
-'
88
-
92
test_expect_success 'last regexp must not be negated' '
93
test_config diff.java.funcname "!static" &&
94
test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
95
grep ": Last expression must not be negated:" msg
96
'
97
95
-test_expect_success 'pattern which matches to end of line' '
96
- test_config diff.java.funcname "Beer\$" &&
97
- test_expect_funcname "Beer\$"
98
-'
99
-
100
-test_expect_success 'alternation in pattern' '
101
- test_config diff.java.funcname "Beer$" &&
102
- test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
103
- test_expect_funcname "public static void main("
104
-'
105
-
98
test_expect_success 'setup hunk header tests' '
99
for i in $diffpatterns
100
do
t/t4018/custom1-pattern
new
+17
@@ -0,0 +1,17 @@
1
+public class Beer
2
+{
3
+ int special, RIGHT;
4
+ public static void main(String args[])
5
+ {
6
+ String s=" ";
7
+ for(int x = 99; x > 0; x--)
8
+ {
9
+ System.out.print(x + " bottles of beer on the wall "
10
+ + x + " bottles of beer\n" // ChangeMe
11
+ + "Take one down, pass it around, " + (x - 1)
12
+ + " bottles of beer on the wall.\n");
13
+ }
14
+ System.out.print("Go to the store, buy some more,\n"
15
+ + "99 bottles of beer on the wall.\n");
16
+ }
17
+}
t/t4018/custom2-match-to-end-of-line
new
+8
@@ -0,0 +1,8 @@
1
+public class RIGHT_Beer
2
+{
3
+ int special;
4
+ public static void main(String args[])
5
+ {
6
+ System.out.print("ChangeMe");
7
+ }
8
+}
t/t4018/custom3-alternation-in-pattern
new
+17
@@ -0,0 +1,17 @@
1
+public class Beer
2
+{
3
+ int special;
4
+ public static void main(String RIGHT[])
5
+ {
6
+ String s=" ";
7
+ for(int x = 99; x > 0; x--)
8
+ {
9
+ System.out.print(x + " bottles of beer on the wall "
10
+ + x + " bottles of beer\n" // ChangeMe
11
+ + "Take one down, pass it around, " + (x - 1)
12
+ + " bottles of beer on the wall.\n");
13
+ }
14
+ System.out.print("Go to the store, buy some more,\n"
15
+ + "99 bottles of beer on the wall.\n");
16
+ }
17
+}