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>
Johannes Sixt committed
Mar 21, 2014 at 22:07 UTC
ad5070fb363b1e7ee7e1df83a17f4e8e1eb607a0
1 file changed
+14
-38
t/t4018-diff-funcname.sh
+14
-38
@@ -7,29 +7,6 @@ test_description='Test custom diff function name patterns'
7
8
. ./test-lib.sh
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
-
10
test_expect_success 'setup' '
11
# a non-trivial custom pattern
12
git config diff.custom1.funcname "!static
@@ -41,7 +18,11 @@ test_expect_success 'setup' '
18
19
# alternation in pattern
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
26
'
27
28
diffpatterns="
@@ -70,29 +51,24 @@ do
51
test_expect_success "builtin $p pattern compiles" '
52
echo "*.java diff=$p" >.gitattributes &&
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
57
'
58
test_expect_success "builtin $p wordRegex pattern compiles" '
59
echo "*.java diff=$p" >.gitattributes &&
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
64
'
65
done
66
86
-test_expect_success 'set up .gitattributes declaring drivers to test' '
87
- cat >.gitattributes <<-\EOF
88
- *.java diff=java
89
- EOF
90
-'
91
-
67
test_expect_success 'last regexp must not be negated' '
68
+ echo "*.java diff=java" >.gitattributes &&
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
72
'
73
74
test_expect_success 'setup hunk header tests' '