Merge from vscode 8a997f7321ae6612fc0e6eb3eac4f358a6233bfb

This commit is contained in:
ADS Merger
2020-02-11 07:08:19 +00:00
parent 0f934081e1
commit 085752f111
217 changed files with 2561 additions and 2063 deletions

View File

@@ -2,29 +2,23 @@
## Run (inside Electron)
The best way to run the unit tests is from the terminal. To make development changes to unit tests you need to be running `yarn watch`. See [Development Workflow](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#incremental-build) for more details. From the `vscode` folder run:
./scripts/test.[sh|bat]
**OS X and Linux**
./scripts/test.sh
**Windows**
scripts\test
All unit tests are run inside a electron-browser environment which access to DOM and Nodejs api. This is the closest to the enviroment in which VS Code itself ships. Notes:
- use the `--debug` to see an electron window with dev tools which allows for debugging
- to run only a subset of tests use the `--run` or `--glob` options
## Run (inside browser)
You can run tests inside a browser instance too:
yarn test-browser --browser webkit --browser chromium
**OS X and Linux**
node test/unit/browser/index.js
**Windows**
node test\unit\browser\index.js
Unit tests from layers `common` and `browser` are run inside `chromium`, `webkit`, and (soonish) `firefox` (using playwright). This complements our electron-based unit test runner and adds more coverage of supported platforms. Notes:
- these tests are part of the continuous build, that means you might have test failures that only happen with webkit on _windows_ or _chromium_ on linux
- you can these tests locally via yarn `test-browser --browser chromium --browser webkit`
- to debug, open `<vscode>/test/unit/browser/renderer.html` inside a browser and use the `?m=<amd_module>`-query to specify what AMD module to load, e.g `file:///Users/jrieken/Code/vscode/test/unit/browser/renderer.html?m=vs/base/test/common/strings.test` runs all tests from `strings.test.ts`
- to run only a subset of tests use the `--run` or `--glob` options
## Run (with node)

View File

@@ -18,7 +18,7 @@ const playwright = require('playwright');
const defaultReporterName = process.platform === 'win32' ? 'list' : 'spec';
const optimist = require('optimist')
// .describe('grep', 'only run tests matching <pattern>').alias('grep', 'g').alias('grep', 'f').string('grep')
// .describe('build', 'run with build output (out-build)').boolean('build')
.describe('build', 'run with build output (out-build)').boolean('build')
.describe('run', 'only run tests matching <relative_file_path>').string('run')
.describe('glob', 'only run tests matching <glob_pattern>').string('glob')
.describe('debug', 'do not run browsers headless').boolean('debug')
@@ -122,6 +122,9 @@ async function runTestsInBrowser(testModules, browserType) {
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug) });
const page = (await browser.defaultContext().pages())[0]
const target = url.pathToFileURL(path.join(__dirname, 'renderer.html'));
if (argv.build) {
target.search = `?build=true`;
}
await page.goto(target.href);
const emitter = new events.EventEmitter();

View File

@@ -37,17 +37,24 @@
});
</script>
<!-- Depending on --build or not, load loader from known locations -->
<script src="../../../out/vs/loader.js"></script>
<script src="../../../out-build/vs/loader.js"></script>
<script>
const urlParams = new URLSearchParams(window.location.search);
const isBuild = urlParams.get('build');
// configure loader
const baseUrl = window.location.href;
require.config({
catchError: true,
baseUrl: new URL('../../../src', baseUrl).href,
paths: {
'vs': new URL('../../../out/vs', baseUrl).href,
'vs': new URL(`../../../${!!isBuild ? 'out-build' : 'out'}/vs`, baseUrl).href,
assert: new URL('../assert.js', baseUrl).href,
sinon: new URL('../../../node_modules/sinon/pkg/sinon-1.17.7.js', baseUrl).href
sinon: new URL('../../../node_modules/sinon/pkg/sinon-1.17.7.js', baseUrl).href,
xterm: new URL('../../../node_modules/xterm/lib/xterm.js', baseUrl).href
}
});
</script>
@@ -104,19 +111,19 @@
window.loadAndRun = async function loadAndRun(modules, manual = false) {
// load
// await Promise.all(modules.map(module => new Promise((resolve, reject) =>{
// require([module], resolve, err => {
// console.log("BAD " + module + JSON.stringify(err, undefined, '\t'));
// // console.log(module);
// resolve({});
// });
// })));
await new Promise((resolve, reject) => {
require(modules, resolve, err => {
console.log(err);
reject(err);
await Promise.all(modules.map(module => new Promise((resolve, reject) => {
require([module], resolve, err => {
console.log("BAD " + module + JSON.stringify(err, undefined, '\t'));
// console.log(module);
resolve({});
});
});
})));
// await new Promise((resolve, reject) => {
// require(modules, resolve, err => {
// console.log(err);
// reject(err);
// });
// });
// run
return new Promise((resolve, reject) => {
@@ -127,7 +134,6 @@
});
}
const modules = new URL(window.location.href).searchParams.getAll('m');
if (Array.isArray(modules) && modules.length > 0) {
console.log('MANUALLY running tests', modules);