t4018 (funcname patterns): make .gitattributes state easier to track

Most, but not all, tests in this script rely on attributes declaring that files with a .java extension should use the "java" driver: *.java diff=java Split out a "set up" test to put such a .gitattributes in place after the tests that do not want it have run, to make it more likely that individual tests other than this setup test can be safely modified, rearranged, or skipped. Presumably this setup code will learn to request other drivers for other extensions in the same place when the test suite learns to exercise other diff drivers. Similarly, make sure that early test assertions that do not use these default attributes set up .gitattributes appropriately for themselves, so tests that run before can be modified with less risk of breaking something. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed May 21, 2011 at 14:11 UTC 5b5e45949bb310fa8972f3e55b9cb05ce8047f37
1 file changed +6 -2
t/t4018-diff-funcname.sh
+6 -2
@@ -36,11 +36,12 @@ builtin_patterns="bibtex cpp csharp fortran html java objc pascal perl php pytho
36 for p in $builtin_patterns
37 do
38 test_expect_success "builtin $p pattern compiles" '
39 - echo "*.java diff=$p" > .gitattributes &&
39 + echo "*.java diff=$p" >.gitattributes &&
40 ! { git diff --no-index Beer.java Beer-correct.java 2>&1 |
41 grep "fatal" > /dev/null; }
42 '
43 test_expect_success "builtin $p wordRegex pattern compiles" '
44 + echo "*.java diff=$p" >.gitattributes &&
45 ! { git diff --no-index --word-diff \
46 Beer.java Beer-correct.java 2>&1 |
47 grep "fatal" > /dev/null; }
@@ -53,8 +54,11 @@ test_expect_success 'default behaviour' '
54 grep "^@@.*@@ public class Beer"
55 '
56
57 +test_expect_success 'set up .gitattributes declaring drivers to test' '
58 + echo "*.java diff=java" >.gitattributes
59 +'
60 +
61 test_expect_success 'preset java pattern' '
57 - echo "*.java diff=java" >.gitattributes &&
62 git diff --no-index Beer.java Beer-correct.java |
63 grep "^@@.*@@ public static void main("
64 '