Git fork

t4018: reduce test files for pattern compilation tests

All test cases that need a file with specific text patterns have been
converted to utilize texts in the t4018/ directory. The remaining tests
in the test script deal only with the validity of the regular
expressions. These tests do not depend on the contents of files that
'git diff' is invoked on. Remove the largish here-document and use only
tiny files.

While we are touching these tests, convert grep to test_i18ngrep as the
texts checked for may undergo translation in the future.

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
ad5070fb f1b75fba

+14 -38
+14 -38
t/t4018-diff-funcname.sh
··· 7 7 8 8 . ./test-lib.sh 9 9 10 - LF=' 11 - ' 12 - cat >Beer.java <<\EOF 13 - public class Beer 14 - { 15 - int special; 16 - public static void main(String args[]) 17 - { 18 - String s=" "; 19 - for(int x = 99; x > 0; x--) 20 - { 21 - System.out.print(x + " bottles of beer on the wall " 22 - + x + " bottles of beer\n" 23 - + "Take one down, pass it around, " + (x - 1) 24 - + " bottles of beer on the wall.\n"); 25 - } 26 - System.out.print("Go to the store, buy some more,\n" 27 - + "99 bottles of beer on the wall.\n"); 28 - } 29 - } 30 - EOF 31 - sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java 32 - 33 10 test_expect_success 'setup' ' 34 11 # a non-trivial custom pattern 35 12 git config diff.custom1.funcname "!static ··· 41 18 42 19 # alternation in pattern 43 20 git config diff.custom3.funcname "Beer$" && 44 - git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" 21 + git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" && 22 + 23 + # for regexp compilation tests 24 + echo A >A.java && 25 + echo B >B.java 45 26 ' 46 27 47 28 diffpatterns=" ··· 70 51 test_expect_success "builtin $p pattern compiles" ' 71 52 echo "*.java diff=$p" >.gitattributes && 72 53 test_expect_code 1 git diff --no-index \ 73 - Beer.java Beer-correct.java 2>msg && 74 - ! grep fatal msg && 75 - ! grep error msg 54 + A.java B.java 2>msg && 55 + ! test_i18ngrep fatal msg && 56 + ! test_i18ngrep error msg 76 57 ' 77 58 test_expect_success "builtin $p wordRegex pattern compiles" ' 78 59 echo "*.java diff=$p" >.gitattributes && 79 60 test_expect_code 1 git diff --no-index --word-diff \ 80 - Beer.java Beer-correct.java 2>msg && 81 - ! grep fatal msg && 82 - ! grep error msg 61 + A.java B.java 2>msg && 62 + ! test_i18ngrep fatal msg && 63 + ! test_i18ngrep error msg 83 64 ' 84 65 done 85 66 86 - test_expect_success 'set up .gitattributes declaring drivers to test' ' 87 - cat >.gitattributes <<-\EOF 88 - *.java diff=java 89 - EOF 90 - ' 91 - 92 67 test_expect_success 'last regexp must not be negated' ' 68 + echo "*.java diff=java" >.gitattributes && 93 69 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 70 + test_expect_code 128 git diff --no-index A.java B.java 2>msg && 71 + test_i18ngrep ": Last expression must not be negated:" msg 96 72 ' 97 73 98 74 test_expect_success 'setup hunk header tests' '