Skip to content

Commit 70404ee

Browse files
kerneltoastclaude
andcommitted
tests: Add fuzzy mode tests for interdiff
Add comprehensive test coverage for the fuzzy diffing mode: - fuzzy1-10: Core fuzzy diffing scenarios including context differences, rejected hunks, real-world kernel patches, and edge cases. - fuzzy11: '\ No newline at end of file' marker handling. - fuzzy12: Addition at line 1 with zero pre-context. - fuzzy13: File deletion (--- a/file, +++ /dev/null) handling. - fuzzy14: Mode-only patches with no diff hunks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent edded43 commit 70404ee

15 files changed

Lines changed: 4047 additions & 1 deletion

File tree

Makefile.am

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,21 @@ TESTS = tests/newline1/run-test \
432432
tests/git-deleted-file/run-test \
433433
tests/git-pure-rename/run-test \
434434
tests/git-diff-edge-cases/run-test \
435-
tests/malformed-diff-headers/run-test
435+
tests/malformed-diff-headers/run-test \
436+
tests/fuzzy1/run-test \
437+
tests/fuzzy2/run-test \
438+
tests/fuzzy3/run-test \
439+
tests/fuzzy4/run-test \
440+
tests/fuzzy5/run-test \
441+
tests/fuzzy6/run-test \
442+
tests/fuzzy7/run-test \
443+
tests/fuzzy8/run-test \
444+
tests/fuzzy9/run-test \
445+
tests/fuzzy10/run-test \
446+
tests/fuzzy11/run-test \
447+
tests/fuzzy12/run-test \
448+
tests/fuzzy13/run-test \
449+
tests/fuzzy14/run-test
436450

437451
# Scanner tests (only when scanner-patchfilter is enabled)
438452
if USE_SCANNER_PATCHFILTER

tests/fuzzy1/run-test

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/sh
2+
3+
# This is an interdiff(1) testcase.
4+
# Test: Fuzzy diffing with one rejected hunk per patched file.
5+
6+
7+
. ${top_srcdir-.}/tests/common.sh
8+
9+
cat << 'EOF' > patch1
10+
--- file
11+
+++ file
12+
@@ -1,4 +1,4 @@
13+
-line 1
14+
+LINE 1
15+
line 2
16+
line 3
17+
line 4
18+
EOF
19+
20+
cat << 'EOF' > patch2
21+
--- file
22+
+++ file
23+
@@ -5,9 +5,6 @@
24+
line 5
25+
if
26+
1
27+
-fi
28+
-if
29+
-2
30+
fi
31+
A
32+
B
33+
EOF
34+
35+
cat << 'EOF' > expected
36+
================================================================================
37+
* DELTA DIFFERENCES - code changes that differ between the patches *
38+
================================================================================
39+
40+
--- file
41+
+++ file
42+
@@ -1,4 +1,4 @@
43+
-LINE 1
44+
+line 1
45+
line 2
46+
line 3
47+
line 4
48+
49+
################################################################################
50+
! REJECTED PATCH2 HUNKS - could not be compared; manual review needed !
51+
################################################################################
52+
53+
--- file
54+
+++ file
55+
@@ -5,9 +5,6 @@
56+
line 5
57+
if
58+
1
59+
-fi
60+
-if
61+
-2
62+
fi
63+
A
64+
B
65+
66+
================================================================================
67+
* CONTEXT DIFFERENCES - surrounding code differences between the patches *
68+
================================================================================
69+
70+
--- file
71+
+++ file
72+
@@ -1,4 +1,9 @@
73+
-line 1
74+
-line 2
75+
-line 3
76+
-line 4
77+
+line 5
78+
+if
79+
+1
80+
+fi
81+
+if
82+
+2
83+
+fi
84+
+A
85+
+B
86+
EOF
87+
88+
${INTERDIFF} --fuzzy patch1 patch2 2>errors >output
89+
[ -s errors ] && exit 1
90+
91+
cmp output expected || exit 1

0 commit comments

Comments
 (0)