File tree Expand file tree Collapse file tree 7 files changed +256
-0
lines changed Expand file tree Collapse file tree 7 files changed +256
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,12 @@ TESTS = tests/newline1/run-test \
320320 tests/grepdiff8/run-test \
321321 tests/grepdiff9/run-test \
322322 tests/grepdiff-original-line-numbers/run-test \
323+ tests/grepdiff-number-files/run-test \
324+ tests/grepdiff-status/run-test \
325+ tests/grepdiff-include-exclude/run-test \
326+ tests/grepdiff-file-regex/run-test \
327+ tests/grepdiff-annotate/run-test \
328+ tests/grepdiff-with-filename/run-test \
323329 tests/number1/run-test \
324330 tests/number2/run-test \
325331 tests/number3/run-test \
@@ -445,6 +451,14 @@ XFAIL_TESTS += \
445451 tests/lsdiff-exclusion-mode/run-test
446452endif
447453
454+ # grepdiff tests: expected to fail when scanner-patchfilter is enabled
455+ # (features not yet implemented in scanner-based grepdiff)
456+ if USE_SCANNER_PATCHFILTER
457+ XFAIL_TESTS += \
458+ tests/grepdiff-status/run-test \
459+ tests/grepdiff-annotate/run-test
460+ endif
461+
448462test-perms : src/combinediff$(EXEEXT ) src/flipdiff$(EXEEXT ) \
449463 src/lsdiff$(EXEEXT ) src/grepdiff$(EXEEXT ) src/patchview$(EXEEXT ) \
450464 scripts/splitdiff
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff --annotate option
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > diff
8+ --- file1
9+ +++ file1
10+ @@ -1,2 +1,2 @@
11+ context
12+ -old
13+ +new
14+ @@ -10 +10 @@
15+ -another
16+ +change
17+ --- file2
18+ +++ file2
19+ @@ -1 +1 @@
20+ -foo
21+ +bar
22+ EOF
23+
24+ ${GREPDIFF} --annotate --output-matching=hunk ' new' diff 2> errors > output || exit 1
25+ [ -s errors ] && exit 1
26+
27+ cat << EOF | cmp - output || exit 1
28+ --- file1
29+ +++ file1
30+ @@ -1,2 +1,2 @@ Hunk #1, file1
31+ context
32+ -old
33+ +new
34+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff -f/--file option (read regexes from file)
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > diff
8+ --- file1
9+ +++ file1
10+ @@ -1 +1 @@
11+ -apple
12+ +banana
13+ --- file2
14+ +++ file2
15+ @@ -1 +1 @@
16+ -cherry
17+ +date
18+ --- file3
19+ +++ file3
20+ @@ -1 +1 @@
21+ -elderberry
22+ +fig
23+ EOF
24+
25+ cat << EOF > patterns
26+ banana
27+ date
28+ EOF
29+
30+ ${GREPDIFF} -f patterns diff 2> errors > output || exit 1
31+ [ -s errors ] && exit 1
32+
33+ cat << EOF | cmp - output || exit 1
34+ file1
35+ file2
36+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff -i/--include and -x/--exclude options
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > diff
8+ --- src/file1.c
9+ +++ src/file1.c
10+ @@ -1 +1 @@
11+ -old
12+ +new
13+ --- docs/readme.txt
14+ +++ docs/readme.txt
15+ @@ -1 +1 @@
16+ -old
17+ +new
18+ --- src/file2.c
19+ +++ src/file2.c
20+ @@ -1 +1 @@
21+ -old
22+ +new
23+ EOF
24+
25+ # Test include pattern
26+ ${GREPDIFF} -i ' *.c' ' new' diff 2> errors > output || exit 1
27+ [ -s errors ] && exit 1
28+
29+ cat << EOF | cmp - output || exit 1
30+ src/file1.c
31+ src/file2.c
32+ EOF
33+
34+ # Test exclude pattern
35+ ${GREPDIFF} -x ' *.txt' ' new' diff 2> errors > output2 || exit 1
36+ [ -s errors ] && exit 1
37+
38+ cat << EOF | cmp - output2 || exit 1
39+ src/file1.c
40+ src/file2.c
41+ EOF
42+
43+ # Test combination of include and exclude
44+ ${GREPDIFF} -i ' src/*' -x ' *file2*' ' new' diff 2> errors > output3 || exit 1
45+ [ -s errors ] && exit 1
46+
47+ cat << EOF | cmp - output3 || exit 1
48+ src/file1.c
49+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff -N/--number-files option
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > diff
8+ --- file1
9+ +++ file1
10+ @@ -1 +1 @@
11+ -old
12+ +new
13+ --- file2
14+ +++ file2
15+ @@ -1 +1 @@
16+ -foo
17+ +bar
18+ --- file3
19+ +++ file3
20+ @@ -1 +1 @@
21+ -test
22+ +result
23+ EOF
24+
25+ ${GREPDIFF} -N ' new' diff 2> errors > output || exit 1
26+ [ -s errors ] && exit 1
27+
28+ cat << EOF | cmp - output || exit 1
29+ File #1 file1
30+ EOF
31+
32+ # Test with multiple matches (pattern matches content in files 1 and 3)
33+ ${GREPDIFF} -N ' [ot]' diff 2> errors > output2 || exit 1
34+ [ -s errors ] && exit 1
35+
36+ cat << EOF | cmp - output2 || exit 1
37+ File #1 file1
38+ File #2 file2
39+ File #3 file3
40+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff -s/--status option
4+ # Shows file status: + (addition), - (removal), ! (modification)
5+
6+ . ${top_srcdir-.} /tests/common.sh
7+
8+ cat << EOF > diff
9+ --- /dev/null
10+ +++ newfile
11+ @@ -0,0 +1 @@
12+ +content
13+ --- oldfile
14+ +++ /dev/null
15+ @@ -1 +0,0 @@
16+ -content
17+ --- modified
18+ +++ modified
19+ @@ -1 +1 @@
20+ -old
21+ +new
22+ EOF
23+
24+ ${GREPDIFF} -s ' content' diff 2> errors > output || exit 1
25+ [ -s errors ] && exit 1
26+
27+ cat << EOF | cmp - output || exit 1
28+ ! newfile
29+ ! oldfile
30+ EOF
31+
32+ # Test with modification
33+ ${GREPDIFF} -s ' new' diff 2> errors > output2 || exit 1
34+ [ -s errors ] && exit 1
35+
36+ cat << EOF | cmp - output2 || exit 1
37+ ! modified
38+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test grepdiff -H/--with-filename and -h/--no-filename options
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > patch1
8+ --- file1
9+ +++ file1
10+ @@ -1 +1 @@
11+ -old
12+ +new
13+ EOF
14+
15+ cat << EOF > patch2
16+ --- file2
17+ +++ file2
18+ @@ -1 +1 @@
19+ -foo
20+ +bar
21+ EOF
22+
23+ # Test with multiple patch files (should show filenames by default)
24+ ${GREPDIFF} ' new' patch1 patch2 2> errors > output || exit 1
25+ [ -s errors ] && exit 1
26+
27+ cat << EOF | cmp - output || exit 1
28+ patch1:file1
29+ EOF
30+
31+ # Test -H explicitly
32+ ${GREPDIFF} -H ' new' patch1 patch2 2> errors > output2 || exit 1
33+ [ -s errors ] && exit 1
34+
35+ cat << EOF | cmp - output2 || exit 1
36+ patch1:file1
37+ EOF
38+
39+ # Test -h to suppress filename
40+ ${GREPDIFF} -h ' new' patch1 patch2 2> errors > output3 || exit 1
41+ [ -s errors ] && exit 1
42+
43+ cat << EOF | cmp - output3 || exit 1
44+ file1
45+ EOF
You can’t perform that action at this time.
0 commit comments