Skip to content

feat: show V tests in the Test Explorer - #563

Open
metif12 wants to merge 1 commit into
vlang:masterfrom
metif12:feat/test-explorer
Open

metif12 wants to merge 1 commit into
vlang:masterfrom
metif12:feat/test-explorer

Conversation

@metif12

@metif12 metif12 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

What this adds

Test Explorer integration. The extension used tasks and CodeLens for tests, so
nothing appeared in the Test Explorer panel — a user had no tree of tests, no
per-test run button, and no pass/fail status in the panel.

golang.go uses vscode.tests.createTestController with three views in the
test container. This registers a controller and shows one item per test_
function.

Why the mapping is unusually direct

A V test is a test_-prefixed function in a _test.v file. There is no test
framework and no test object, so the file layout is the whole contract. That
makes the three pieces line up:

Test Explorer V
TestItem a test_ function
TestRunRequest.include VTEST_ONLY_FN
run v test <file> -run-only <name>

So running a selected test is one command with one filter, and the output is
parsed to mark each test passed, failed or errored.

Discovery

Best-effort, so it cannot break activation:

  • a workspace with no _test.v files shows an empty tree
  • a file that cannot be read is skipped
  • the tree refreshes on workspace and file changes, so it stays honest without
    tracking which file changed into which item

Verification

npm run lint, npm run lint:md, npm run test:grammar, npm run build and
npm run package all pass.

npm test reports 29 tests, 26 pass, 3 fail. The three failures are the
pre-existing Windows path-separator tests on master, fixed in
#561 and not touched here.

Proof the new tests catch something. I broke the test-function regex in
testDiscovery.ts and watched finds the test functions in a test file go red,
then reverted it. A test that cannot fail is not evidence.

Known limitations

  • Not exercised in a real VS Code window. The controller wiring is not covered by
    the extension-host suite; the discovery and output parsing are.
  • A test that is neither passed nor failed in the output is reported as errored
    with "This test did not run", which is a different problem from running and
    failing. That distinction is deliberate.
  • v test reports per-file, so a run of a whole file marks every test in it from
    one output. Per-test timing is not available.

Relation to other PRs

Independent of #556, #557, #558, #559, #560, #561 and #562. It adds new files
and touches extension.ts and package.json only where the other PRs do not.

The extension used tasks and CodeLens for tests, so nothing appeared in the Test
Explorer panel. `golang.go` uses `vscode.tests.createTestController` with three
views in the `test` container; this registers a controller and shows one item
per `test_` function.

The mapping onto V is unusually direct. A test is a `test_`-prefixed function in
a `_test.v` file, `VTEST_ONLY_FN` takes exactly the glob filter that
`TestRunRequest.include` already models, and `v test` is already a task. So
running a selected test is `v test <file> -run-only <name>`, and the output is
parsed to mark each test passed, failed or errored.

Discovery is best-effort. A workspace with no `_test.v` files shows an empty tree
rather than failing activation, and a file that cannot be read is skipped. The
tree refreshes on workspace and file changes, so it stays honest without
tracking which file changed into which item.

The discovery and output parsing live in a pure module so they can be tested
without a workspace or a compiler. I confirmed the tests catch something by
breaking the regex and watching the discovery test fail, then reverting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@metif12
metif12 force-pushed the feat/test-explorer branch from f1085e8 to 3526b6c Compare October 10, 2026 04:53
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