Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs-site/src/content/docs/guides/test-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ The ExTester offers both CLI and API to perform all the setup actions. That way
- `HTTP_PROXY` - route http requests through a proxy when downloading VS Code and ChromeDriver (see also `HTTPS_PROXY`).
- `HTTPS_PROXY` / `NO_PROXY` - proxy for the https downloads of VS Code and ChromeDriver, and the usual no-proxy exception list.
- `EXTENSIONS_FOLDER` - configuring the [extension path](https://code.visualstudio.com/docs/configure/extensions/extension-marketplace#_where-are-extensions-installed) where extensions are installed/loaded.
- `EXTENSION_DEV_PATH` - The [developer extension](https://vscode-docs.readthedocs.io/en/stable/extensions/debugging-extensions/) that is loaded under development.
- `EXTENSION_DEV_PATH` - The [developer extension](https://vscode-docs.readthedocs.io/en/stable/extensions/debugging-extensions/) that is loaded under development. ExTester passes it to VS Code as `--extensionDevelopmentPath`, so the extension is loaded from that folder instead of from an installed `.vsix`. Every test run honours it; `extest setup-and-run --coverage` overrides it with the current working directory, because that is the extension being instrumented.

```shell
export EXTENSION_DEV_PATH="$(pwd)"
```
- `HTTPS_TLS_REJECT_UNAUTHORIZED` - Disable TLS check when downloading VSCode and Chromium driver. '0' is disabled and '1' is enabled, this setting aligns with [`NODE_TLS_REJECT_UNAUTHORIZED`](https://nodejs.org/api/cli.html#node_tls_reject_unauthorizedvalue).

```shell
Expand Down
33 changes: 33 additions & 0 deletions packages/extester/src/test/codeUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,43 @@ import {
flagConflictWarnings,
findShadowedSettings,
resolveMacExecutable,
applyExtensionDevPath,
} from '../util/codeUtil';
import { ReleaseQuality } from '../util/codeUtil';
import { Download } from '../util/download';

describe('applyExtensionDevPath', () => {
it('keeps a user-supplied EXTENSION_DEV_PATH when coverage is off', () => {
const env: NodeJS.ProcessEnv = { EXTENSION_DEV_PATH: '/home/me/my-extension' };
applyExtensionDevPath(false, '/tmp/instrumented', env);
assert.strictEqual(env.EXTENSION_DEV_PATH, '/home/me/my-extension');
});

it('leaves EXTENSION_DEV_PATH absent when neither coverage nor the user set it', () => {
const env: NodeJS.ProcessEnv = {};
applyExtensionDevPath(undefined, '/tmp/instrumented', env);
assert.ok(!('EXTENSION_DEV_PATH' in env));
});

it('overrides a user-supplied EXTENSION_DEV_PATH with the working directory when coverage is on', () => {
const env: NodeJS.ProcessEnv = { EXTENSION_DEV_PATH: '/home/me/my-extension' };
applyExtensionDevPath(true, '/tmp/instrumented', env);
assert.strictEqual(env.EXTENSION_DEV_PATH, '/tmp/instrumented');
});

it('sets EXTENSION_DEV_PATH from the working directory when coverage is on and the user set nothing', () => {
const env: NodeJS.ProcessEnv = {};
applyExtensionDevPath(true, '/tmp/instrumented', env);
assert.strictEqual(env.EXTENSION_DEV_PATH, '/tmp/instrumented');
});

it('mutates only EXTENSION_DEV_PATH', () => {
const env: NodeJS.ProcessEnv = { EXTENSION_DEV_PATH: '/home/me/my-extension', TEST_RESOURCES: '/tmp/test-resources' };
applyExtensionDevPath(false, '/tmp/instrumented', env);
assert.deepStrictEqual(env, { EXTENSION_DEV_PATH: '/home/me/my-extension', TEST_RESOURCES: '/tmp/test-resources' });
});
});

describe('CodeUtil.packageExtension', () => {
let originalCreateVSIX: typeof vsce.createVSIX;
let capturedOptions: IPackageOptions | undefined;
Expand Down
29 changes: 24 additions & 5 deletions packages/extester/src/util/codeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,29 @@ export function validateUserDataDirLength(settingsDir: string, platform: NodeJS.
return undefined;
}

/**
* Applies the `EXTENSION_DEV_PATH` environment variable for a test run.
*
* `EXTENSION_DEV_PATH` is a documented, user-facing variable that makes ExTester
* launch VS Code with `--extensionDevelopmentPath`, which loads an extension straight
* from a folder instead of from an installed `.vsix`.
*
* When coverage is enabled the instrumented extension is whatever lives in the current
* working directory, so that value has to win. In every other case the variable is left
* exactly as the caller exported it: deleting it here silently dropped
* `--extensionDevelopmentPath` from the launch arguments, so a user-supplied path had no
* effect on the run.
*
* @param coverage whether the run instruments the extension in the current working directory
* @param cwd the directory of the extension being instrumented
* @param env the environment to mutate, defaults to `process.env`
*/
export function applyExtensionDevPath(coverage: boolean | undefined, cwd: string, env: NodeJS.ProcessEnv = process.env): void {
if (coverage) {
env.EXTENSION_DEV_PATH = cwd;
}
}

/** defaults for the [[RunOptions]] */
export const DEFAULT_RUN_OPTIONS = {
vscodeVersion: 'latest',
Expand Down Expand Up @@ -694,11 +717,7 @@ export class CodeUtil {
} else {
delete process.env.EXTENSIONS_FOLDER;
}
if (this.coverage) {
process.env.EXTENSION_DEV_PATH = process.cwd();
} else {
delete process.env.EXTENSION_DEV_PATH;
}
applyExtensionDevPath(this.coverage, process.cwd());
const runner = new VSRunner(
this.getExecutablePath(),
literalVersion,
Expand Down
Loading