Git fork

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>

authored by

Johannes Sixt and committed by
Junio C Hamano
f1b75fba dd4dc5c5

+58 -24
+16 -24
t/t4018-diff-funcname.sh
··· 30 30 EOF 31 31 sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java 32 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 + ' 39 46 40 47 diffpatterns=" 41 48 ada ··· 53 60 python 54 61 ruby 55 62 tex 63 + custom1 64 + custom2 65 + custom3 56 66 " 57 67 58 68 for p in $diffpatterns ··· 79 89 EOF 80 90 ' 81 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 - 89 92 test_expect_success 'last regexp must not be negated' ' 90 93 test_config diff.java.funcname "!static" && 91 94 test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg && 92 95 grep ": Last expression must not be negated:" msg 93 - ' 94 - 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 96 ' 105 97 106 98 test_expect_success 'setup hunk header tests' '
+17
t/t4018/custom1-pattern
··· 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 + }
+8
t/t4018/custom2-match-to-end-of-line
··· 1 + public class RIGHT_Beer 2 + { 3 + int special; 4 + public static void main(String args[]) 5 + { 6 + System.out.print("ChangeMe"); 7 + } 8 + }
+17
t/t4018/custom3-alternation-in-pattern
··· 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 + }