userdiff: add support for Scheme
[git.git] / t / t4018-diff-funcname.sh
blob823ea96acba4fd67c4ce7f84838be41e06380d89
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test custom diff function name patterns'
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 # a non-trivial custom pattern
12 git config diff.custom1.funcname "!static
13 !String
14 [^ ].*s.*" &&
16 # a custom pattern which matches to end of line
17 git config diff.custom2.funcname "......Beer\$" &&
19 # alternation in pattern
20 git config diff.custom3.funcname "Beer$" &&
21 git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" &&
23 # for regexp compilation tests
24 echo A >A.java &&
25 echo B >B.java
28 diffpatterns="
29 ada
30 bash
31 bibtex
32 cpp
33 csharp
34 css
35 dts
36 elixir
37 fortran
38 fountain
39 golang
40 html
41 java
42 markdown
43 matlab
44 objc
45 pascal
46 perl
47 php
48 python
49 ruby
50 rust
51 scheme
52 tex
53 custom1
54 custom2
55 custom3
58 for p in $diffpatterns
60 test_expect_success "builtin $p pattern compiles" '
61 echo "*.java diff=$p" >.gitattributes &&
62 test_expect_code 1 git diff --no-index \
63 A.java B.java 2>msg &&
64 test_i18ngrep ! fatal msg &&
65 test_i18ngrep ! error msg
67 test_expect_success "builtin $p wordRegex pattern compiles" '
68 echo "*.java diff=$p" >.gitattributes &&
69 test_expect_code 1 git diff --no-index --word-diff \
70 A.java B.java 2>msg &&
71 test_i18ngrep ! fatal msg &&
72 test_i18ngrep ! error msg
74 done
76 test_expect_success 'last regexp must not be negated' '
77 echo "*.java diff=java" >.gitattributes &&
78 test_config diff.java.funcname "!static" &&
79 test_expect_code 128 git diff --no-index A.java B.java 2>msg &&
80 test_i18ngrep ": Last expression must not be negated:" msg
83 test_expect_success 'setup hunk header tests' '
84 for i in $diffpatterns
86 echo "$i-* diff=$i"
87 done > .gitattributes &&
89 # add all test files to the index
91 cd "$TEST_DIRECTORY"/t4018 &&
92 git --git-dir="$TRASH_DIRECTORY/.git" add .
93 ) &&
95 # place modified files in the worktree
96 for i in $(git ls-files)
98 sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
99 done
102 # check each individual file
103 for i in $(git ls-files)
105 if grep broken "$i" >/dev/null 2>&1
106 then
107 result=failure
108 else
109 result=success
111 test_expect_$result "hunk header: $i" "
112 git diff -U1 $i >actual &&
113 grep '@@ .* @@.*RIGHT' actual
115 done
117 test_done