File tree Expand file tree Collapse file tree 6 files changed +221
-0
lines changed
lsdiff-empty-files-removed Expand file tree Collapse file tree 6 files changed +221
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,11 @@ TESTS = tests/newline1/run-test \
290290 tests/lsdiff13/run-test \
291291 tests/lsdiff14/run-test \
292292 tests/lsdiff15/run-test \
293+ tests/lsdiff-number-files/run-test \
294+ tests/lsdiff-files-range/run-test \
295+ tests/lsdiff-empty-files-removed/run-test \
296+ tests/lsdiff-addprefix/run-test \
297+ tests/lsdiff-strip-match/run-test \
293298 tests/lsdiff-hunks-option/run-test \
294299 tests/lsdiff-lines-option/run-test \
295300 tests/lsdiff-exclusion-combined/run-test \
@@ -459,6 +464,14 @@ XFAIL_TESTS += \
459464 tests/grepdiff-annotate/run-test
460465endif
461466
467+ # lsdiff tests: expected to fail when scanner-patchfilter is enabled
468+ # (features not yet implemented in scanner-based lsdiff)
469+ if USE_SCANNER_PATCHFILTER
470+ XFAIL_TESTS += \
471+ tests/lsdiff-empty-files-removed/run-test \
472+ tests/lsdiff-strip-match/run-test
473+ endif
474+
462475test-perms : src/combinediff$(EXEEXT ) src/flipdiff$(EXEEXT ) \
463476 src/lsdiff$(EXEEXT ) src/grepdiff$(EXEEXT ) src/patchview$(EXEEXT ) \
464477 scripts/splitdiff
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test lsdiff --addprefix 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+ EOF
19+
20+ ${LSDIFF} --addprefix=prefix/ diff 2> errors > output || exit 1
21+ [ -s errors ] && exit 1
22+
23+ cat << EOF | cmp - output || exit 1
24+ prefix/file1
25+ prefix/file2
26+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test lsdiff -E/--empty-files-as-removed option
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ # Create diffs where files become empty or start empty
8+ mkdir dir dir.orig
9+
10+ # File that becomes empty (modified -> empty)
11+ echo content > dir.orig/becomes-empty
12+ touch dir/becomes-empty
13+
14+ # File that starts empty (empty -> modified)
15+ touch dir.orig/was-empty
16+ echo content > dir/was-empty
17+
18+ # Normal modification
19+ echo old > dir.orig/modified
20+ echo new > dir/modified
21+
22+ ${DIFF} -uN dir.orig dir > diff
23+
24+ # Without -E, files that are/become empty show as modifications
25+ ${LSDIFF} -s --strip=1 diff 2> errors > output1 || exit 1
26+ [ -s errors ] && exit 1
27+
28+ cat << EOF | cmp - output1 || exit 1
29+ ! becomes-empty
30+ ! modified
31+ ! was-empty
32+ EOF
33+
34+ # With -E, treat empty files as absent
35+ # becomes-empty: content->empty = treated as removal
36+ # was-empty: empty->content = treated as addition
37+ ${LSDIFF} -sE --strip=1 diff 2> errors > output2 || exit 1
38+ [ -s errors ] && exit 1
39+
40+ cat << EOF | cmp - output2 || exit 1
41+ - becomes-empty
42+ ! modified
43+ + was-empty
44+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test lsdiff -F/--files=RANGE 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+ --- file4
24+ +++ file4
25+ @@ -1 +1 @@
26+ -data
27+ +value
28+ EOF
29+
30+ # Test single file
31+ ${LSDIFF} -F2 diff 2> errors > output1 || exit 1
32+ [ -s errors ] && exit 1
33+
34+ cat << EOF | cmp - output1 || exit 1
35+ file2
36+ EOF
37+
38+ # Test range
39+ ${LSDIFF} -F2-3 diff 2> errors > output2 || exit 1
40+ [ -s errors ] && exit 1
41+
42+ cat << EOF | cmp - output2 || exit 1
43+ file2
44+ file3
45+ EOF
46+
47+ # Test open-ended range
48+ ${LSDIFF} -F3- diff 2> errors > output3 || exit 1
49+ [ -s errors ] && exit 1
50+
51+ cat << EOF | cmp - output3 || exit 1
52+ file3
53+ file4
54+ EOF
55+
56+ # Test exclusion range
57+ ${LSDIFF} -Fx2-3 diff 2> errors > output4 || exit 1
58+ [ -s errors ] && exit 1
59+
60+ cat << EOF | cmp - output4 || exit 1
61+ file1
62+ file4
63+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test lsdiff -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+ ${LSDIFF} -N diff 2> errors > output || exit 1
26+ [ -s errors ] && exit 1
27+
28+ cat << EOF | cmp - output || exit 1
29+ File #1 file1
30+ File #2 file2
31+ File #3 file3
32+ EOF
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Test lsdiff -p/--strip-match option
4+
5+ . ${top_srcdir-.} /tests/common.sh
6+
7+ cat << EOF > diff
8+ --- a/src/file1.c
9+ +++ b/src/file1.c
10+ @@ -1 +1 @@
11+ -old
12+ +new
13+ --- a/docs/readme.txt
14+ +++ b/docs/readme.txt
15+ @@ -1 +1 @@
16+ -old
17+ +new
18+ --- a/src/file2.c
19+ +++ b/src/file2.c
20+ @@ -1 +1 @@
21+ -old
22+ +new
23+ EOF
24+
25+ # Use -p to strip 'a/' and 'b/' prefixes when matching
26+ # Include only files in src/ directory
27+ # Note: -p affects matching, output still shows original paths from diff
28+ ${LSDIFF} -p1 -i ' src/*' diff 2> errors > output || exit 1
29+ [ -s errors ] && exit 1
30+
31+ cat << EOF | cmp - output || exit 1
32+ a/src/file1.c
33+ a/src/file2.c
34+ EOF
35+
36+ # Test that we can use --strip to also strip output
37+ ${LSDIFF} -p1 -i ' src/*' --strip=1 diff 2> errors > output2 || exit 1
38+ [ -s errors ] && exit 1
39+
40+ cat << EOF | cmp - output2 || exit 1
41+ src/file1.c
42+ src/file2.c
43+ EOF
You can’t perform that action at this time.
0 commit comments