From 7fb452a94bf67c89fa7233fa17245a8e263be60d Mon Sep 17 00:00:00 2001 From: Dominik Jelinek Date: Tue, 30 May 2023 21:46:44 +0200 Subject: [PATCH] issue-726: Add support for installing dependencies in the extest install-vsix command Signed-off-by: Dominik Jelinek --- src/cli.ts | 3 ++- src/extester.ts | 13 ++++++++----- src/util/codeUtil.ts | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index d060aca80..b38621986 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -35,9 +35,10 @@ program.command('install-vsix') .option('-f, --vsix_file ', 'path/URL to vsix file containing the extension') .option('-y, --yarn', 'Use yarn to build the extension via vsce instead of npm', false) .option('-t, --type ', 'Type of VSCode release (stable/insider)') + .option('-i, --install_dependencies', 'Automatically install extensions your extension depends on', false) .action(withErrors(async (cmd) => { const extest = new ExTester(cmd.storage, codeStream(cmd.type), cmd.extensions_dir); - await extest.installVsix({vsixFile: cmd.vsix_file, useYarn: cmd.yarn}); + await extest.installVsix({vsixFile: cmd.vsix_file, useYarn: cmd.yarn, installDependencies: cmd.install_dependencies}); })); program.command('install-from-marketplace [ids...]') diff --git a/src/extester.ts b/src/extester.ts index e3b389334..538889783 100644 --- a/src/extester.ts +++ b/src/extester.ts @@ -46,7 +46,7 @@ export class ExTester { * @param version version to download, default latest */ async downloadCode(version: string = 'latest'): Promise { - return this.code.downloadVSCode(loadCodeVersion(version)); + return await this.code.downloadVSCode(loadCodeVersion(version)); } /** @@ -54,7 +54,7 @@ export class ExTester { * @param vsixFile path to extension .vsix file. If not set, default vsce path will be used * @param useYarn when true run `vsce package` with the `--yarn` flag */ - async installVsix({vsixFile, useYarn}: {vsixFile?: string, useYarn?: boolean} = {}): Promise { + async installVsix({vsixFile, useYarn, installDependencies}: {vsixFile?: string, useYarn?: boolean, installDependencies?: boolean} = {}): Promise { let target = vsixFile; if (vsixFile) { try { @@ -73,7 +73,10 @@ export class ExTester { } else { await this.code.packageExtension(useYarn); } - return this.code.installExtension(target); + this.code.installExtension(target); + if (installDependencies) { + this.code.installDependencies(); + } } /** @@ -133,7 +136,7 @@ export class ExTester { */ async setupAndRunTests(testFilesPattern: string | string[], vscodeVersion: string = 'latest', setupOptions: Omit = DEFAULT_SETUP_OPTIONS, runOptions: Omit = DEFAULT_RUN_OPTIONS): Promise { await this.setupRequirements({...setupOptions, vscodeVersion}, runOptions.offline); - return this.runTests(testFilesPattern, {...runOptions, vscodeVersion}); + return await this.runTests(testFilesPattern, {...runOptions, vscodeVersion}); } /** @@ -146,7 +149,7 @@ export class ExTester { async runTests(testFilesPattern: string | string[], runOptions: RunOptions = DEFAULT_RUN_OPTIONS): Promise { runOptions.vscodeVersion = loadCodeVersion(runOptions.vscodeVersion); const patterns = (typeof testFilesPattern === 'string') ? ([testFilesPattern]) : (testFilesPattern); - return this.code.runTests(patterns, runOptions); + return await this.code.runTests(patterns, runOptions); } } diff --git a/src/util/codeUtil.ts b/src/util/codeUtil.ts index 9a7495629..0b8933532 100644 --- a/src/util/codeUtil.ts +++ b/src/util/codeUtil.ts @@ -247,7 +247,7 @@ export class CodeUtil { process.env.TEST_RESOURCES = this.downloadFolder; process.env.EXTENSIONS_FOLDER = this.extensionsFolder; const runner = new VSRunner(this.executablePath, literalVersion, this.parseSettings(runOptions.settings ?? DEFAULT_RUN_OPTIONS.settings), runOptions.cleanup, this.releaseType, runOptions.config); - return runner.runTests(testFilesPattern, this, runOptions.logLevel, runOptions.resources); + return await runner.runTests(testFilesPattern, this, runOptions.logLevel, runOptions.resources); } /**