Skip to content

Commit

Permalink
t4018 (funcname patterns): make .gitattributes state easier to track
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed May 22, 2011
1 parent 9963e02 commit 5b5e459
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions t/t4018-diff-funcname.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ builtin_patterns="bibtex cpp csharp fortran html java objc pascal perl php pytho
for p in $builtin_patterns
do
test_expect_success "builtin $p pattern compiles" '
echo "*.java diff=$p" > .gitattributes &&
echo "*.java diff=$p" >.gitattributes &&
! { git diff --no-index Beer.java Beer-correct.java 2>&1 |
grep "fatal" > /dev/null; }
'
test_expect_success "builtin $p wordRegex pattern compiles" '
echo "*.java diff=$p" >.gitattributes &&
! { git diff --no-index --word-diff \
Beer.java Beer-correct.java 2>&1 |
grep "fatal" > /dev/null; }
Expand All @@ -53,8 +54,11 @@ test_expect_success 'default behaviour' '
grep "^@@.*@@ public class Beer"
'

test_expect_success 'set up .gitattributes declaring drivers to test' '
echo "*.java diff=java" >.gitattributes
'

test_expect_success 'preset java pattern' '
echo "*.java diff=java" >.gitattributes &&
git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ public static void main("
'
Expand Down

0 comments on commit 5b5e459

Please sign in to comment.