Skip to content

Commit ad5070f

Browse files
j6tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1b75fb commit ad5070f

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

t/t4018-diff-funcname.sh

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,6 @@ test_description='Test custom diff function name patterns'
77

88
. ./test-lib.sh
99

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-
3310
test_expect_success 'setup' '
3411
# a non-trivial custom pattern
3512
git config diff.custom1.funcname "!static
@@ -41,7 +18,11 @@ test_expect_success 'setup' '
4118
4219
# alternation in pattern
4320
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
4526
'
4627

4728
diffpatterns="
@@ -70,29 +51,24 @@ do
7051
test_expect_success "builtin $p pattern compiles" '
7152
echo "*.java diff=$p" >.gitattributes &&
7253
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
7657
'
7758
test_expect_success "builtin $p wordRegex pattern compiles" '
7859
echo "*.java diff=$p" >.gitattributes &&
7960
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
8364
'
8465
done
8566

86-
test_expect_success 'set up .gitattributes declaring drivers to test' '
87-
cat >.gitattributes <<-\EOF
88-
*.java diff=java
89-
EOF
90-
'
91-
9267
test_expect_success 'last regexp must not be negated' '
68+
echo "*.java diff=java" >.gitattributes &&
9369
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
9672
'
9773

9874
test_expect_success 'setup hunk header tests' '

0 commit comments

Comments
 (0)