Skip to content

fix(codeUtil): keep a user-supplied EXTENSION_DEV_PATH when coverage is off - #2584

Merged
djelinek merged 2 commits into
redhat-developer:mainfrom
haigou-web:fix/extension-dev-path
Oct 22, 2026
Merged

djelinek merged 2 commits into
redhat-developer:mainfrom
haigou-web:fix/extension-dev-path

Conversation

@haigou-web

Copy link
Copy Markdown
Contributor

Closes #2023

Problem

CodeUtil.runTests() deleted EXTENSION_DEV_PATH whenever coverage was off:

if (this.coverage) {
	process.env.EXTENSION_DEV_PATH = process.cwd();
} else {
	delete process.env.EXTENSION_DEV_PATH;
}

EXTENSION_DEV_PATH is documented in guides/test-setup.md as a supported environment variable, and it is the only thing that makes VSBrowser add --extensionDevelopmentPath to the launch arguments. Deleting it meant a value the caller had exported never reached VS Code, so extest run-tests could not run tests against a compiled extension — the commands the extension contributes were simply absent, as reported in the issue.

Fix

The environment preparation moved into applyExtensionDevPath(), which writes the variable only when coverage is enabled and otherwise leaves the caller's value untouched:

export function applyExtensionDevPath(coverage: boolean | undefined, cwd: string, env: NodeJS.ProcessEnv = process.env): void {
	if (coverage) {
		env.EXTENSION_DEV_PATH = cwd;
	}
}

extest setup-and-run --coverage keeps winning, because in that mode the instrumented extension really is the one in the working directory.

Tests

Five unit tests in codeUtil.test.ts cover the new function:

applyExtensionDevPath
  √ keeps a user-supplied EXTENSION_DEV_PATH when coverage is off
  √ leaves EXTENSION_DEV_PATH absent when neither coverage nor the user set it
  √ overrides a user-supplied EXTENSION_DEV_PATH with the working directory when coverage is on
  √ sets EXTENSION_DEV_PATH from the working directory when coverage is on and the user set nothing
  √ mutates only EXTENSION_DEV_PATH

5 passing

Full unit suite: 157 passing, 2 pending via npx tsc -p ./ && npx mocha 'out/test/**/*.test.js'.

Docs

guides/test-setup.md now says the variable is honoured on every run and that --coverage overrides it, instead of leaving that conflict implicit.

Notes for reviewers

  • I could not run the UI suite (npm run test:build) — it needs a real VS Code plus ChromeDriver. The change only affects the environment handed to the runner, and the unit tests exercise it directly.
  • EXTENSION_DEV_PATH has exactly one reader (VSBrowser), so dropping the delete cannot affect other code paths.
  • Unrelated, found while building on Windows and left alone: packages/extester's build script runs chmod a+x ./out/cli.js, which does not exist on Windows, so npm run build fails there even on a clean checkout.

…is off

`runTests()` deleted `EXTENSION_DEV_PATH` whenever coverage was disabled:

    if (this.coverage) {
        process.env.EXTENSION_DEV_PATH = process.cwd();
    } else {
        delete process.env.EXTENSION_DEV_PATH;
    }

`EXTENSION_DEV_PATH` is a documented environment variable that makes ExTester
launch VS Code with `--extensionDevelopmentPath`, so the deletion silently
dropped that argument for every non-coverage run and a user-supplied path had no
effect. It is why `extest run-tests` could not run tests against a compiled
extension instead of an installed `.vsix`.

The environment preparation now lives in `applyExtensionDevPath()`, which only
writes the variable when coverage is enabled and otherwise leaves the caller's
value untouched. `extest setup-and-run --coverage` still wins, because that run
instruments the extension in the working directory.

Closes redhat-developer#2023

Signed-off-by: haigou-web <haigou@users.noreply.github.com>
@haigou-web
haigou-web requested a review from a team as a code owner October 6, 2026 14:25
@sonarqubecloud

Copy link
Copy Markdown

@djelinek

Copy link
Copy Markdown
Collaborator

Thank you for your contribution!

@djelinek
djelinek merged commit 701f6e8 into redhat-developer:main Oct 22, 2026
173 of 175 checks passed
@kurmasz

kurmasz commented Oct 22, 2026

Copy link
Copy Markdown

Thanks for the fix.

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.

EXTENSION_DEV_PATH appears to have no effect on run-tests

4 participants