Skip to content

Commit 042c0f5

Browse files
committed
Fix off-by-one errors in HunkMatcher diff remap tests
Two tests passed the wrong oldLine value (off by +1), causing the remapped result to be 1 higher than expected: - parseDiffAndRemap with multiple hunks: 6→5 - parseDiffAndRemap with single line hunk: 7→6 Also remove diagnostic CI step no longer needed. https://claude.ai/code/session_015LpmjAt17XD582hZ9TPLCv
1 parent 9028a18 commit 042c0f5

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ jobs:
4545
- name: Run tests
4646
run: ./gradlew test --stacktrace
4747

48-
- name: Print test results on failure
49-
if: failure()
50-
run: |
51-
echo "=== TEST RESULTS XML ==="
52-
find build/test-results -name '*.xml' -exec cat {} \; 2>/dev/null || echo "No XML results found"
53-
echo "=== STDOUT/STDERR ==="
54-
find build/test-results -name '*.txt' -exec cat {} \; 2>/dev/null || echo "No text output found"
55-
echo "=== GRADLE TEST REPORT ==="
56-
find build/reports/tests -name '*.html' -exec grep -l 'failures' {} \; 2>/dev/null || echo "No HTML reports found"
57-
for f in $(find build/reports/tests -name '*.html' 2>/dev/null); do
58-
echo "--- $f ---"
59-
cat "$f" | sed 's/<[^>]*>//g' | head -100
60-
done
61-
6248
- name: Upload test results
6349
if: always()
6450
uses: actions/upload-artifact@v4

review-plugin/src/test/kotlin/com/reviewplugin/anchor/HunkMatcherTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class HunkMatcherTest {
159159
""".trimIndent()
160160
// After first hunk: offset = (2+3)-(2+2) = 1
161161
// Old line 5 is between hunks → 5 - 1 + 1 = 5 (0-based)
162-
assertEquals(5, HunkMatcher.parseDiffAndRemap(diff, 6))
162+
assertEquals(5, HunkMatcher.parseDiffAndRemap(diff, 5))
163163
}
164164

165165
@Test
@@ -174,7 +174,7 @@ class HunkMatcherTest {
174174
// Old line 5 is in the hunk (5..5)
175175
assertNull(HunkMatcher.parseDiffAndRemap(diff, 5))
176176
// Old line 6 is after: offset = (5+2)-(5+1) = 1, result = 6-1+1 = 6
177-
assertEquals(6, HunkMatcher.parseDiffAndRemap(diff, 7))
177+
assertEquals(6, HunkMatcher.parseDiffAndRemap(diff, 6))
178178
}
179179

180180
// ── fuzzySearch ─────────────────────────────────────────────────

0 commit comments

Comments
 (0)