зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
dd4dc5c574
Коммит
f1b75fbaf1
|
@ -30,12 +30,19 @@ public class Beer
|
|||
EOF
|
||||
sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java
|
||||
|
||||
test_expect_funcname () {
|
||||
lang=${2-java}
|
||||
test_expect_code 1 git diff --no-index -U1 \
|
||||
"Beer.$lang" "Beer-correct.$lang" >diff &&
|
||||
grep "^@@.*@@ $1" diff
|
||||
}
|
||||
test_expect_success 'setup' '
|
||||
# a non-trivial custom pattern
|
||||
git config diff.custom1.funcname "!static
|
||||
!String
|
||||
[^ ].*s.*" &&
|
||||
|
||||
# a custom pattern which matches to end of line
|
||||
git config diff.custom2.funcname "......Beer\$" &&
|
||||
|
||||
# alternation in pattern
|
||||
git config diff.custom3.funcname "Beer$" &&
|
||||
git config diff.custom3.xfuncname "^[ ]*((public|static).*)$"
|
||||
'
|
||||
|
||||
diffpatterns="
|
||||
ada
|
||||
|
@ -53,6 +60,9 @@ diffpatterns="
|
|||
python
|
||||
ruby
|
||||
tex
|
||||
custom1
|
||||
custom2
|
||||
custom3
|
||||
"
|
||||
|
||||
for p in $diffpatterns
|
||||
|
@ -79,30 +89,12 @@ test_expect_success 'set up .gitattributes declaring drivers to test' '
|
|||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'custom pattern' '
|
||||
test_config diff.java.funcname "!static
|
||||
!String
|
||||
[^ ].*s.*" &&
|
||||
test_expect_funcname "int special;\$"
|
||||
'
|
||||
|
||||
test_expect_success 'last regexp must not be negated' '
|
||||
test_config diff.java.funcname "!static" &&
|
||||
test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
|
||||
grep ": Last expression must not be negated:" msg
|
||||
'
|
||||
|
||||
test_expect_success 'pattern which matches to end of line' '
|
||||
test_config diff.java.funcname "Beer\$" &&
|
||||
test_expect_funcname "Beer\$"
|
||||
'
|
||||
|
||||
test_expect_success 'alternation in pattern' '
|
||||
test_config diff.java.funcname "Beer$" &&
|
||||
test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
|
||||
test_expect_funcname "public static void main("
|
||||
'
|
||||
|
||||
test_expect_success 'setup hunk header tests' '
|
||||
for i in $diffpatterns
|
||||
do
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
public class Beer
|
||||
{
|
||||
int special, RIGHT;
|
||||
public static void main(String args[])
|
||||
{
|
||||
String s=" ";
|
||||
for(int x = 99; x > 0; x--)
|
||||
{
|
||||
System.out.print(x + " bottles of beer on the wall "
|
||||
+ x + " bottles of beer\n" // ChangeMe
|
||||
+ "Take one down, pass it around, " + (x - 1)
|
||||
+ " bottles of beer on the wall.\n");
|
||||
}
|
||||
System.out.print("Go to the store, buy some more,\n"
|
||||
+ "99 bottles of beer on the wall.\n");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
public class RIGHT_Beer
|
||||
{
|
||||
int special;
|
||||
public static void main(String args[])
|
||||
{
|
||||
System.out.print("ChangeMe");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
public class Beer
|
||||
{
|
||||
int special;
|
||||
public static void main(String RIGHT[])
|
||||
{
|
||||
String s=" ";
|
||||
for(int x = 99; x > 0; x--)
|
||||
{
|
||||
System.out.print(x + " bottles of beer on the wall "
|
||||
+ x + " bottles of beer\n" // ChangeMe
|
||||
+ "Take one down, pass it around, " + (x - 1)
|
||||
+ " bottles of beer on the wall.\n");
|
||||
}
|
||||
System.out.print("Go to the store, buy some more,\n"
|
||||
+ "99 bottles of beer on the wall.\n");
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче