vscode-test/README.md

153 строки
4.2 KiB
Markdown
Исходник Обычный вид История

2019-05-24 03:00:27 +03:00
<p>
<h1 align="center">vscode-test</h1>
</p>
<p align="center">
<a href="https://dev.azure.com/vscode/vscode-test/_build?definitionId=15">
<img src="https://img.shields.io/azure-devops/build/vscode/350ef5c4-15fc-411a-9a5e-0622da4da69c/15.svg?label=Azure%20DevOps&logo=Azure%20Devops&style=flat-square">
2019-05-24 03:00:27 +03:00
</a>
2019-06-28 03:03:52 +03:00
<a href="https://travis-ci.org/microsoft/vscode-test">
<img src="https://img.shields.io/travis/microsoft/vscode-test.svg?label=Travis&logo=Travis&style=flat-square">
</a>
2019-05-24 03:00:27 +03:00
</p>
2019-03-14 21:33:54 +03:00
2019-03-20 08:20:11 +03:00
This module helps you test VS Code extensions.
2019-03-14 21:33:54 +03:00
Supported:
2019-05-23 21:17:22 +03:00
- Node >= 8.x
2019-05-24 11:41:00 +03:00
- Windows >= Windows Server 2012+ / Win10+ (anything with Powershell >= 5.0)
- macOS
- Linux
2019-03-14 21:33:54 +03:00
## Usage
2019-08-02 01:52:03 +03:00
See [./sample](./sample) for a runnable sample, with [Azure DevOps Pipelines](https://github.com/microsoft/vscode-test/blob/master/sample/azure-pipelines.yml) and [Travis CI](https://github.com/microsoft/vscode-test/blob/master/.travis.yml) configuration.
2019-03-14 21:44:45 +03:00
2019-03-14 21:33:54 +03:00
```ts
async function go() {
2019-09-25 21:37:26 +03:00
try {
const extensionDevelopmentPath = path.resolve(__dirname, '../../../')
const extensionTestsPath = path.resolve(__dirname, './suite')
/**
* Basic usage
*/
await runTests({
extensionDevelopmentPath,
extensionTestsPath
})
const extensionTestsPath2 = path.resolve(__dirname, './suite2')
const testWorkspace = path.resolve(__dirname, '../../../test-fixtures/fixture1')
/**
* Running another test suite on a specific workspace
*/
await runTests({
extensionDevelopmentPath,
extensionTestsPath: extensionTestsPath2,
launchArgs: [testWorkspace]
})
/**
* Use 1.36.1 release for testing
*/
await runTests({
version: '1.36.1',
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
/**
* Use Insiders release for testing
*/
await runTests({
version: 'insiders',
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
/**
* 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.
*/
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0')
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [testWorkspace]
})
/**
* Install Python extension
*/
const cliPath = resolveCliPathFromVSCodeExecutablePath(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,
extensionTestsPath,
launchArgs: [
testWorkspace,
// This disables all extensions except the one being testing
'--disable-extensions'
],
// Custom environment variables for extension test script
extensionTestsEnv: { foo: 'bar' }
})
2019-12-12 00:19:31 +03:00
/**
* Use win64 instead of win32 for testing Windows
*/
if (process.platform === 'win32') {
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
version: '1.40.0',
platform: 'win32-x64-archive'
});
}
2019-09-25 21:37:26 +03:00
} catch (err) {
console.error('Failed to run tests')
process.exit(1)
}
2019-03-14 21:33:54 +03:00
}
2019-09-25 21:37:26 +03:00
go()
2019-03-14 21:33:54 +03:00
```
## License
[MIT](LICENSE)
## Contributing
2019-06-27 15:38:45 +03:00
This project welcomes contributions and suggestions. Most contributions require you to agree to a
2019-03-14 21:33:54 +03:00
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.