Skip to content

Add test coverage for the Unified Diff display - #2830

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-test-coverage
Jul 29, 2026
Merged

Add test coverage for the Unified Diff display#2830
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-test-coverage

Conversation

@vogella

@vogella vogella commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The unified diff feature has roughly 190 lines of test code for about 3000 lines of implementation, and the trickiest parts (the offset and line geometry behind the code minings) were unreachable from a test because they lived as private helpers inside the SWT drawing code. This moves those pure functions into a new internal UnifiedDiffText class and covers them, together with the diff modes, from org.eclipse.team.tests.core.

The integration tests pin the contracts that actually matter: REPLACE_MODE must turn the document into the compared source, which is where the cumulative offset delta across several diffs is easy to get wrong; the overlay and revert modes must leave the document untouched; reopening must replace the previous diffs instead of stacking them; and closing the editor must clear the manager's static per-viewer map. On the unit side the merged style ranges are checked to tile the syntax colouring exactly, since StyledText#setStyleRanges throws on overlapping ranges.

One behaviour change comes along with the extraction. The two line counts in UnifiedDiffLineHeaderCodeMining#draw used String#split("\n"), which drops trailing empty strings, so a detailed diff starting exactly at a line start was highlighted one line too high. They now use the extracted countLines.

The tests run under the ui-test target of test.xml via AllTeamUITests, where both classes are registered.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   57m 17s ⏱️ -25s
 4 690 tests ±0   4 668 ✅ ±0   22 💤 ±0  0 ❌ ±0 
11 964 runs  ±0  11 811 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit 410530c. ± Comparison against base commit 77eecda.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the unified-diff-test-coverage branch from 8072a45 to 12af42a Compare July 28, 2026 15:34
Extract the offset and line geometry helpers behind the unified diff code
minings into a new internal UnifiedDiffText class so they can be tested,
and cover them together with the diff modes in org.eclipse.team.tests.core.

Also fixes the line counting in UnifiedDiffLineHeaderCodeMining#draw, which
used String#split("\n") and therefore placed the detailed diff highlight one
line too high when a diff started at a line start.
@vogella
vogella force-pushed the unified-diff-test-coverage branch from 12af42a to 410530c Compare July 28, 2026 18:11
@vogella
vogella merged commit 01a0d46 into eclipse-platform:master Jul 29, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant