Skip to content

feat: run tests with coverage and show it in the editor - #19

Merged
Sam Gammon (sgammon) merged 1 commit into
mainfrom
feat/test-coverage
Oct 13, 2026
Merged

Sam Gammon (sgammon) merged 1 commit into
mainfrom
feat/test-coverage

Conversation

@sgammon

@sgammon Sam Gammon (sgammon) commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What

A Run with Coverage test profile, next to Run and Debug. It runs elide test --coverage (plus the usual --reporter=tap and -t pattern) and, once the run exits, publishes the coverage reports Elide wrote to VS Code's coverage gutter, inline view and Test Coverage view. Each line gets a statement count and branch counts (FileCoverage.fromDetails + loadDetailedCoverage).

Why

Until now --coverage could only be passed through elide.test.options, and its results were never shown in the editor.

Where Elide writes coverage (checked on real binaries, samples/ktjvm and a TypeScript project)

Elide 1.6.0-rc.2 (1.6.0+865db8f07d) Elide 1.5.4
Guest JS/TS .dev/reports/coverage/js/lcov.info (LCOV, absolute SF: paths, DA lines only) same, but paths can carry /./
JVM .dev/reports/coverage/jvm/<task>/<task>.exec .dev/artifacts/coverage/jvm/<task>/<task>.exec
JVM XML (beside the .exec) when the manifest has coverage { jvm { reports { Coverage.xmlReport() } } } when it has testing { coverage { jvm { reports { Jvm.xmlReport() } } } }

JaCoCo .exec data only means something together with the compiled classes and the JaCoCo analyzer, which the IntelliJ plugin bundles and an extension cannot. JVM coverage is therefore read from the JaCoCo XML report. If a run leaves only .exec, the run output says to ask for the XML report, giving both spellings of the setting. The two spellings cannot both appear in one manifest (each Elide rejects the other's), so samples/ktjvm is unchanged. The integration test appends the right one for the installed Elide.

No run code lens or launch-config path is included. On rc.2 elide run --coverage writes .dev/reports/coverage/jvm/run/run.{exec,xml} for a JVM main, but nothing for a TypeScript entrypoint. On 1.5.4 it writes no file at all. Run lenses run as tasks, while VS Code's coverage API hangs off a test run. Wiring the two together is a follow-up once that output is settled.

How

  • packages/core/src/coverage.ts: finds reports under both layouts, keeping only files modified since the run started; decodes LCOV (DA, BRDA) and JaCoCo XML (<sourcefile>/<line nr mi ci mb cb>, resolved against the project's source roots by package and file name); merges by path; restates LCOV paths for a project opened through a symlink.
  • packages/vscode/src/testing.ts: the profile, --coverage on the invocation, publishing per covered project (a whole workspace run covers its members), and the .exec-only hint. ElideTestApi.runAll({ coverage: true }) returns per-file statement counts for the integration test, which gains a coverage step.

Verification

  • bun run build, bun run --filter elide typecheck, bun run test (138 pass, 11 new in coverage.test.ts), bun run --filter elide package.
  • Unit fixtures are real reports from Elide 1.6.0-rc.2: lcov.info from elide test --coverage on a TypeScript project, and jacoco.xml from samples/ktjvm with a branching classify function. The project root is replaced with /project and the session id with a placeholder.
  • The coverage block the integration test appends (import("elide:Coverage.pkl").xmlReport() / import("elide:Jvm.pkl").xmlReport()) was checked with elide test --coverage on rc.2 and 1.5.4: each writes jvm-test.xml.
  • End to end in VS Code 1.141.0 (downloaded by @vscode/test-electron, under Xvfb) on a copy of samples/ktjvm plus a Classify.kt, driven through runAll({ coverage: true }):
    • Elide 1.5.4, this branch, legacy block: Main.kt 1/4 statements, Classify.kt 0/3, MainTest.kt 3/3.
    • Elide 1.6.0-rc.2, this branch merged locally with fix: sync with elide project export, falling back to elide manifest #18 (which 1.6 needs for sync at all), current block: same counts. A screenshot showed lines 4–6 of Main.kt red, greeting green with a 1x hit badge, and the Test Coverage view at src 28.57%, Main.kt 25%, MainTest.kt 100%.
    • Elide 1.6.0-rc.2 with no XML report requested: no file coverage published (only .exec present), so the hint path runs.
  • The full local integration suite (bun run test:integration) was not run. It needs the 1.2 GB JetBrains.kotlin-server extension, which is not installed here; the runs above used a stub of it.

Adds a Run with Coverage test profile. It runs elide test --coverage and publishes the guest LCOV
and JVM JaCoCo XML reports the run writes under .dev to VS Code's coverage gutter and Test Coverage
view, with per-line branch counts. JaCoCo execution data alone cannot be read, so it earns a hint to
ask for the XML report in the manifest.

Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon
Sam Gammon (sgammon) merged commit 7746bd2 into main Oct 13, 2026
3 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