Коммит
c7efccb001
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
### 1.1.0
|
||||
|
||||
- Add `resolveCliPathFromExecutablePath` that would resolve `vscodeExecutablePath` to path of VS Code CLI, which can be used
|
||||
for extension management such as `--install-extension` and `--uninstall-extension`. [#31](https://github.com/microsoft/vscode-test/issues/31).
|
||||
|
||||
### 1.0.2 | 2019-07-17
|
||||
|
||||
- Revert faulty fix for #29.
|
||||
|
|
|
@ -93,6 +93,15 @@ async function go() {
|
|||
launchArgs: [testWorkspace]
|
||||
})
|
||||
|
||||
/**
|
||||
* Install Python extension
|
||||
*/
|
||||
const cliPath = resolveCliPathFromExecutablePath(vscodeExecutablePath);
|
||||
cp.spawnSync(cliPath, ['--install-extension', 'ms-python.python'], {
|
||||
encoding: 'utf-8',
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
/**
|
||||
* - Add additional launch flags for VS Code.
|
||||
* - Pass custom environment variables to test runner.
|
||||
|
|
|
@ -128,6 +128,8 @@ function unzipVSCode(vscodeArchivePath: string) {
|
|||
* `'stable'` for downloading latest stable release.
|
||||
* `'insiders'` for downloading latest Insiders.
|
||||
* When unspecified, download latest stable version.
|
||||
*
|
||||
* @returns Pormise of `vscodeExecutablePath`.
|
||||
*/
|
||||
export async function downloadAndUnzipVSCode(version?: DownloadVersion): Promise<string> {
|
||||
if (version && version !== 'stable') {
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
|
||||
export { downloadAndUnzipVSCode } from './download';
|
||||
export { runTests } from './runTest';
|
||||
export { resolveCliPathFromExecutablePath } from './util';
|
||||
|
|
36
lib/util.ts
36
lib/util.ts
|
@ -72,3 +72,39 @@ export function insidersDownloadDirToExecutablePath(dir: string) {
|
|||
return path.resolve(dir, 'VSCode-linux-x64/code-insiders');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the VS Code cli path from executable path returned from `downloadAndUnzipVSCode`.
|
||||
* You can use this path to spawn processes for extension management. For example:
|
||||
*
|
||||
* ```ts
|
||||
* const cp = require('child_process');
|
||||
* const { downloadAndUnzipVSCode, resolveCliPathFromExecutablePath } = require('vscode-test')
|
||||
* const vscodeExecutablePath = await downloadAndUnzipVSCode('1.36.0');
|
||||
* const cliPath = resolveCliPathFromExecutablePath(vscodeExecutablePath);
|
||||
*
|
||||
* cp.spawnSync(cliPath, ['--install-extension', '<EXTENSION-ID-OR-PATH-TO-VSIX>'], {
|
||||
* encoding: 'utf-8',
|
||||
* stdio: 'inherit'
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param vscodeExecutablePath The `vscodeExecutablePath` from `downloadAndUnzipVSCode`.
|
||||
*/
|
||||
export function resolveCliPathFromExecutablePath(vscodeExecutablePath: string) {
|
||||
if (process.platform === 'win32') {
|
||||
if (vscodeExecutablePath.endsWith('Code - Insiders.exe')) {
|
||||
return path.resolve(vscodeExecutablePath, '../bin/code-insiders.cmd');
|
||||
} else {
|
||||
return path.resolve(vscodeExecutablePath, '../bin/code.cmd');
|
||||
}
|
||||
} else if (process.platform === 'darwin') {
|
||||
return path.resolve(vscodeExecutablePath, '../../../Contents/Resources/app/bin/code');
|
||||
} else {
|
||||
if (vscodeExecutablePath.endsWith('code-insiders')) {
|
||||
return path.resolve(vscodeExecutablePath, '../bin/code-insiders');
|
||||
} else {
|
||||
return path.resolve(vscodeExecutablePath, '../bin/code');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as path from 'path'
|
||||
import * as cp from 'child_process'
|
||||
|
||||
import { runTests, downloadAndUnzipVSCode } from '../../lib/index'
|
||||
import { runTests, downloadAndUnzipVSCode, resolveCliPathFromExecutablePath } from '../../lib/index'
|
||||
|
||||
async function go() {
|
||||
try {
|
||||
|
@ -9,8 +10,8 @@ async function go() {
|
|||
const testWorkspace = path.resolve(__dirname, '../../test-fixtures/fixture1')
|
||||
|
||||
/**
|
||||
* Basic usage
|
||||
*/
|
||||
* Basic usage
|
||||
*/
|
||||
await runTests({
|
||||
extensionDevelopmentPath,
|
||||
extensionTestsPath
|
||||
|
@ -20,8 +21,8 @@ async function go() {
|
|||
const testWorkspace2 = path.resolve(__dirname, '../../test-fixtures/fixture2')
|
||||
|
||||
/**
|
||||
* Running a second test suite
|
||||
*/
|
||||
* Running a second test suite
|
||||
*/
|
||||
await runTests({
|
||||
extensionDevelopmentPath,
|
||||
extensionTestsPath: extensionTestsPath2,
|
||||
|
@ -29,8 +30,8 @@ async function go() {
|
|||
})
|
||||
|
||||
/**
|
||||
* Use 1.36.1 release for testing
|
||||
*/
|
||||
* Use 1.36.1 release for testing
|
||||
*/
|
||||
await runTests({
|
||||
version: '1.36.1',
|
||||
extensionDevelopmentPath,
|
||||
|
@ -39,8 +40,8 @@ async function go() {
|
|||
})
|
||||
|
||||
/**
|
||||
* Use Insiders release for testing
|
||||
*/
|
||||
* Use Insiders release for testing
|
||||
*/
|
||||
await runTests({
|
||||
version: 'insiders',
|
||||
extensionDevelopmentPath,
|
||||
|
@ -49,13 +50,13 @@ async function go() {
|
|||
})
|
||||
|
||||
/**
|
||||
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
|
||||
*/
|
||||
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
|
||||
*/
|
||||
await downloadAndUnzipVSCode('1.36.1')
|
||||
|
||||
/**
|
||||
* Manually download VS Code 1.35.0 release for testing.
|
||||
*/
|
||||
* Manually download VS Code 1.35.0 release for testing.
|
||||
*/
|
||||
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0')
|
||||
await runTests({
|
||||
vscodeExecutablePath,
|
||||
|
@ -65,9 +66,18 @@ async function go() {
|
|||
})
|
||||
|
||||
/**
|
||||
* - Add additional launch flags for VS Code
|
||||
* - Pass custom environment variables to test runner
|
||||
*/
|
||||
* Install Python extension
|
||||
*/
|
||||
const cliPath = resolveCliPathFromExecutablePath(vscodeExecutablePath)
|
||||
cp.spawnSync(cliPath, ['--install-extension', 'ms-python.python'], {
|
||||
encoding: 'utf-8',
|
||||
stdio: 'inherit'
|
||||
})
|
||||
|
||||
/**
|
||||
* - Add additional launch flags for VS Code
|
||||
* - Pass custom environment variables to test runner
|
||||
*/
|
||||
await runTests({
|
||||
vscodeExecutablePath,
|
||||
extensionDevelopmentPath,
|
||||
|
@ -80,7 +90,6 @@ async function go() {
|
|||
// Custom environment variables for extension test script
|
||||
extensionTestsEnv: { foo: 'bar' }
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests')
|
||||
process.exit(1)
|
||||
|
|
Загрузка…
Ссылка в новой задаче