Skip to content

Commit

Permalink
issue-726: Add support for installing dependencies in the extest inst…
Browse files Browse the repository at this point in the history
…all-vsix command

Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek committed Jun 2, 2023
1 parent 0ca2ac4 commit 7fb452a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ program.command('install-vsix')
.option('-f, --vsix_file <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>', '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 <id> [ids...]')
Expand Down
13 changes: 8 additions & 5 deletions src/extester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export class ExTester {
* @param version version to download, default latest
*/
async downloadCode(version: string = 'latest'): Promise<void> {
return this.code.downloadVSCode(loadCodeVersion(version));
return await this.code.downloadVSCode(loadCodeVersion(version));
}

/**
* Install the extension into the test instance of VS Code
* @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<void> {
async installVsix({vsixFile, useYarn, installDependencies}: {vsixFile?: string, useYarn?: boolean, installDependencies?: boolean} = {}): Promise<void> {
let target = vsixFile;
if (vsixFile) {
try {
Expand All @@ -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();
}
}

/**
Expand Down Expand Up @@ -133,7 +136,7 @@ export class ExTester {
*/
async setupAndRunTests(testFilesPattern: string | string[], vscodeVersion: string = 'latest', setupOptions: Omit<SetupOptions, "vscodeVersion"> = DEFAULT_SETUP_OPTIONS, runOptions: Omit<RunOptions, "vscodeVersion"> = DEFAULT_RUN_OPTIONS): Promise<number> {
await this.setupRequirements({...setupOptions, vscodeVersion}, runOptions.offline);
return this.runTests(testFilesPattern, {...runOptions, vscodeVersion});
return await this.runTests(testFilesPattern, {...runOptions, vscodeVersion});
}

/**
Expand All @@ -146,7 +149,7 @@ export class ExTester {
async runTests(testFilesPattern: string | string[], runOptions: RunOptions = DEFAULT_RUN_OPTIONS): Promise<number> {
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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/codeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 7fb452a

Please sign in to comment.