Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new option testRunnerDataDir #68

Merged
merged 1 commit into from
Mar 29, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## 0.0.37
* new option `--testRunnerDataDir` to set the temporary folder for storing the VS Code builds used for running the tests


## 0.0.28
* new option `--coi` to enable cross origin isolation.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ CLI options:
| --open-devtools | If set, opens the dev tools in the browser. |
| --verbose | If set, prints out more information when running the server. |
| --printServerLog | If set, prints the server access log. |
| --testRunnerDataDir | If set, the temporary folder for storing the VS Code builds used for running the tests |
| folderPath | A local folder to open VS Code on. The folder content will be available as a virtual file system and opened as workspace. |

Corresponding options are available in the API.
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/test-web",
"version": "0.0.36",
"version": "0.0.37",
"scripts": {
"install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample",
"compile": "tsc -p ./ && yarn compile-fs-provider",
Expand Down Expand Up @@ -30,7 +30,7 @@
"koa-mount": "^4.0.0",
"koa-static": "^5.0.0",
"minimist": "^1.2.8",
"playwright": "^1.32.0",
"playwright": "^1.32.1",
"vscode-uri": "^3.0.7",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
Expand All @@ -39,19 +39,19 @@
"get-stream": "6.0.1"
},
"devDependencies": {
"@types/koa": "^2.13.5",
"@types/koa": "^2.13.6",
"@types/koa-morgan": "^1.0.5",
"@types/koa-mount": "^4.0.2",
"@types/koa-static": "^4.0.2",
"@types/koa__router": "^12.0.0",
"@types/minimist": "^1.2.2",
"@types/node": "16.x",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@types/decompress": "^4.2.4",
"eslint": "^8.36.0",
"eslint": "^8.37.0",
"eslint-plugin-header": "^3.1.1",
"typescript": "^4.9.5"
"typescript": "^5.0.2"
},
"license": "MIT",
"author": "Visual Studio Code Team",
Expand Down
19 changes: 15 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export interface Options {
* The host name to start the server on. Defaults to `localhost`
*/
host?: string;

/**
* The temporary folder for storing the VS Code builds used for running the tests. Defaults to `$CURRENT_WORKING_DIR/.vscode-test-web`.
*/
testRunnerDataDir?: string;
}

export interface Disposable {
Expand Down Expand Up @@ -214,7 +219,8 @@ async function getBuild(options: Options): Promise<Static | Sources> {
};
}
const quality = options.quality || options.version;
return await downloadAndUnzipVSCode(quality === 'stable' ? 'stable' : 'insider');
const testRunnerDataDir = options.testRunnerDataDir ?? path.resolve(process.cwd(), '.vscode-test-web')
return await downloadAndUnzipVSCode(quality === 'stable' ? 'stable' : 'insider', testRunnerDataDir);
}

export async function open(options: Options): Promise<Disposable> {
Expand Down Expand Up @@ -506,6 +512,7 @@ interface CommandLineOptions {
coi?: boolean;
esm?: boolean;
help?: boolean;
testRunnerDataDir?: string;
}

function showHelp() {
Expand All @@ -528,6 +535,7 @@ function showHelp() {
console.log(` --open-devtools: If set, opens the dev tools. [Optional]`);
console.log(` --verbose: If set, prints out more information when running the server. [Optional]`);
console.log(` --printServerLog: If set, prints the server access log. [Optional]`);
console.log(` --testRunnerDataDir: If set, the temporary folder for storing the VS Code builds used for running the tests. [Optional, defaults to '$CURRENT_WORKING_DIR/.vscode-test-web']`);
console.log(` folderPath. A local folder to open VS Code on. The folder content will be available as a virtual file system. [Optional]`);
}

Expand All @@ -544,7 +552,7 @@ async function cliMain(): Promise<void> {
console.log(`${manifest.name}: ${manifest.version}`);

const options: minimist.Opts = {
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserType', 'quality', 'version', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port'],
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserType', 'quality', 'version', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port', 'testRunnerDataDir'],
boolean: ['open-devtools', 'headless', 'hideServerLog', 'printServerLog', 'help', 'verbose', 'coi', 'esm'],
unknown: arg => {
if (arg.startsWith('-')) {
Expand Down Expand Up @@ -577,6 +585,7 @@ async function cliMain(): Promise<void> {
const host = validateStringOrUndefined(args, 'host');
const coi = validateBooleanOrUndefined(args, 'coi');
const esm = validateBooleanOrUndefined(args, 'esm');
const testRunnerDataDir = validateStringOrUndefined(args, 'testRunnerDataDir');

const waitForDebugger = validatePortNumber(args.waitForDebugger);

Expand Down Expand Up @@ -615,7 +624,8 @@ async function cliMain(): Promise<void> {
esm,
coi,
host,
port
port,
testRunnerDataDir
}).catch(e => {
console.log('Error running tests:', e);
process.exit(1);
Expand All @@ -639,7 +649,8 @@ async function cliMain(): Promise<void> {
esm,
coi,
host,
port
port,
testRunnerDataDir
})
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/server/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ interface DownloadInfo {
version: string;
}

const extensionRoot = process.cwd();
const vscodeTestDir = path.resolve(extensionRoot, '.vscode-test-web');


async function getLatestVersion(quality: 'stable' | 'insider'): Promise<DownloadInfo> {
const update: DownloadInfo = await fetchJSON(`https://update.code.visualstudio.com/api/update/web-standalone/${quality}/latest`);
return update;
Expand Down Expand Up @@ -87,7 +83,7 @@ async function unzip(source: string, destination: string, message: string) {
process.stdout.write(`${reset}${message}: complete\n`);
}

export async function downloadAndUnzipVSCode(quality: 'stable' | 'insider'): Promise<Static> {
export async function downloadAndUnzipVSCode(quality: 'stable' | 'insider', vscodeTestDir: string): Promise<Static> {
const info = await getLatestVersion(quality);

const folderName = `vscode-web-${quality}-${info.version}`;
Expand All @@ -105,7 +101,7 @@ export async function downloadAndUnzipVSCode(quality: 'stable' | 'insider'): Pro

const productName = `VS Code ${quality === 'stable' ? 'Stable' : 'Insiders'}`;

const tmpArchiveName = `vscode-web-${quality}-${info.version}-tmp`;
const tmpArchiveName = path.join(vscodeTestDir, `vscode-web-${quality}-${info.version}-tmp`);
try {
await download(info.url, tmpArchiveName, `Downloading ${productName}`);
await unzip(tmpArchiveName, downloadedPath, `Unpacking ${productName}`);
Expand Down
Loading