Move test/all.js to test/unit/node/all.js
This commit is contained in:
parent
e48debc94e
commit
5e8dabc1f4
|
@ -15,7 +15,7 @@
|
||||||
"compile": "gulp compile --max_old_space_size=4095",
|
"compile": "gulp compile --max_old_space_size=4095",
|
||||||
"watch": "gulp watch --max_old_space_size=4095",
|
"watch": "gulp watch --max_old_space_size=4095",
|
||||||
"watch-client": "gulp watch-client --max_old_space_size=4095",
|
"watch-client": "gulp watch-client --max_old_space_size=4095",
|
||||||
"monaco-editor-test": "mocha --only-monaco-editor",
|
"mocha": "mocha test/unit/node/all.js --delay",
|
||||||
"precommit": "node build/gulpfile.hygiene.js",
|
"precommit": "node build/gulpfile.hygiene.js",
|
||||||
"gulp": "gulp --max_old_space_size=8192",
|
"gulp": "gulp --max_old_space_size=8192",
|
||||||
"electron": "node build/lib/electron",
|
"electron": "node build/lib/electron",
|
||||||
|
|
|
@ -11,38 +11,38 @@ const path = require('path');
|
||||||
const glob = require('glob');
|
const glob = require('glob');
|
||||||
const jsdom = require('jsdom-no-contextify');
|
const jsdom = require('jsdom-no-contextify');
|
||||||
const TEST_GLOB = '**/test/**/*.test.js';
|
const TEST_GLOB = '**/test/**/*.test.js';
|
||||||
const coverage = require('./coverage');
|
const coverage = require('../../coverage');
|
||||||
|
|
||||||
var optimist = require('optimist')
|
const optimist = require('optimist')
|
||||||
.usage('Run the Code tests. All mocha options apply.')
|
.usage('Run the Code tests. All mocha options apply.')
|
||||||
.describe('build', 'Run from out-build').boolean('build')
|
.describe('build', 'Run from out-build').boolean('build')
|
||||||
.describe('run', 'Run a single file').string('run')
|
.describe('run', 'Run a single file').string('run')
|
||||||
.describe('coverage', 'Generate a coverage report').boolean('coverage')
|
.describe('coverage', 'Generate a coverage report').boolean('coverage')
|
||||||
.describe('only-monaco-editor', 'Run only monaco editor tests').boolean('only-monaco-editor')
|
|
||||||
.describe('browser', 'Run tests in a browser').boolean('browser')
|
.describe('browser', 'Run tests in a browser').boolean('browser')
|
||||||
.alias('h', 'help').boolean('h')
|
.alias('h', 'help').boolean('h')
|
||||||
.describe('h', 'Show help');
|
.describe('h', 'Show help');
|
||||||
|
|
||||||
var argv = optimist.argv;
|
const argv = optimist.argv;
|
||||||
|
|
||||||
if (argv.help) {
|
if (argv.help) {
|
||||||
optimist.showHelp();
|
optimist.showHelp();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = argv.build ? 'out-build' : 'out';
|
const REPO_ROOT = path.join(__dirname, '../../../');
|
||||||
var loader = require('../' + out + '/vs/loader');
|
const out = argv.build ? 'out-build' : 'out';
|
||||||
var src = path.join(path.dirname(__dirname), out);
|
const loader = require(`../../../${out}/vs/loader`);
|
||||||
|
const src = path.join(REPO_ROOT, out);
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
process.on('uncaughtException', function (e) {
|
process.on('uncaughtException', function (e) {
|
||||||
console.error(e.stack || e);
|
console.error(e.stack || e);
|
||||||
});
|
});
|
||||||
|
|
||||||
var loaderConfig = {
|
const loaderConfig = {
|
||||||
nodeRequire: require,
|
nodeRequire: require,
|
||||||
nodeMain: __filename,
|
nodeMain: __filename,
|
||||||
baseUrl: path.join(path.dirname(__dirname), 'src'),
|
baseUrl: path.join(REPO_ROOT, 'src'),
|
||||||
paths: {
|
paths: {
|
||||||
'vs/css': '../test/css.mock',
|
'vs/css': '../test/css.mock',
|
||||||
'vs': `../${out}/vs`,
|
'vs': `../${out}/vs`,
|
||||||
|
@ -75,17 +75,17 @@ function main() {
|
||||||
global.navigator = global.window.navigator;
|
global.navigator = global.window.navigator;
|
||||||
global.XMLHttpRequest = global.window.XMLHttpRequest;
|
global.XMLHttpRequest = global.window.XMLHttpRequest;
|
||||||
|
|
||||||
var didErr = false;
|
let didErr = false;
|
||||||
var write = process.stderr.write;
|
const write = process.stderr.write;
|
||||||
process.stderr.write = function (data) {
|
process.stderr.write = function (data) {
|
||||||
didErr = didErr || !!data;
|
didErr = didErr || !!data;
|
||||||
write.apply(process.stderr, arguments);
|
write.apply(process.stderr, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadFunc = null;
|
let loadFunc = null;
|
||||||
|
|
||||||
if (argv.runGlob) {
|
if (argv.runGlob) {
|
||||||
loadFunc = cb => {
|
loadFunc = (cb) => {
|
||||||
const doRun = tests => {
|
const doRun = tests => {
|
||||||
const modulesToLoad = tests.map(test => {
|
const modulesToLoad = tests.map(test => {
|
||||||
if (path.isAbsolute(test)) {
|
if (path.isAbsolute(test)) {
|
||||||
|
@ -100,41 +100,19 @@ function main() {
|
||||||
glob(argv.runGlob, { cwd: src }, function (err, files) { doRun(files); });
|
glob(argv.runGlob, { cwd: src }, function (err, files) { doRun(files); });
|
||||||
};
|
};
|
||||||
} else if (argv.run) {
|
} else if (argv.run) {
|
||||||
var tests = (typeof argv.run === 'string') ? [argv.run] : argv.run;
|
const tests = (typeof argv.run === 'string') ? [argv.run] : argv.run;
|
||||||
var modulesToLoad = tests.map(function (test) {
|
const modulesToLoad = tests.map(function (test) {
|
||||||
test = test.replace(/^src/, 'out');
|
test = test.replace(/^src/, 'out');
|
||||||
test = test.replace(/\.ts$/, '.js');
|
test = test.replace(/\.ts$/, '.js');
|
||||||
return path.relative(src, path.resolve(test)).replace(/(\.js)|(\.js\.map)$/, '').replace(/\\/g, '/');
|
return path.relative(src, path.resolve(test)).replace(/(\.js)|(\.js\.map)$/, '').replace(/\\/g, '/');
|
||||||
});
|
});
|
||||||
loadFunc = cb => {
|
loadFunc = (cb) => {
|
||||||
define(modulesToLoad, () => cb(null), cb);
|
define(modulesToLoad, () => cb(null), cb);
|
||||||
};
|
};
|
||||||
} else if (argv['only-monaco-editor']) {
|
|
||||||
loadFunc = function (cb) {
|
|
||||||
glob(TEST_GLOB, { cwd: src }, function (err, files) {
|
|
||||||
var modulesToLoad = files.map(function (file) {
|
|
||||||
return file.replace(/\.js$/, '');
|
|
||||||
});
|
|
||||||
modulesToLoad = modulesToLoad.filter(function (module) {
|
|
||||||
if (/^vs\/workbench\//.test(module)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// platform tests drag in the workbench.
|
|
||||||
// see https://github.com/Microsoft/vscode/commit/12eaba2f64c69247de105c3d9c47308ac6e44bc9
|
|
||||||
// and cry a little
|
|
||||||
if (/^vs\/platform\//.test(module)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !/(\/|\\)node(\/|\\)/.test(module);
|
|
||||||
});
|
|
||||||
console.log(JSON.stringify(modulesToLoad, null, '\t'));
|
|
||||||
define(modulesToLoad, function () { cb(null); }, cb);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
loadFunc = function (cb) {
|
loadFunc = (cb) => {
|
||||||
glob(TEST_GLOB, { cwd: src }, function (err, files) {
|
glob(TEST_GLOB, { cwd: src }, function (err, files) {
|
||||||
var modulesToLoad = files.map(function (file) {
|
const modulesToLoad = files.map(function (file) {
|
||||||
return file.replace(/\.js$/, '');
|
return file.replace(/\.js$/, '');
|
||||||
});
|
});
|
||||||
define(modulesToLoad, function () { cb(null); }, cb);
|
define(modulesToLoad, function () { cb(null); }, cb);
|
||||||
|
@ -160,7 +138,7 @@ function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// report failing test for every unexpected error during any of the tests
|
// report failing test for every unexpected error during any of the tests
|
||||||
var unexpectedErrors = [];
|
let unexpectedErrors = [];
|
||||||
suite('Errors', function () {
|
suite('Errors', function () {
|
||||||
test('should not have unexpected errors in tests', function () {
|
test('should not have unexpected errors in tests', function () {
|
||||||
if (unexpectedErrors.length) {
|
if (unexpectedErrors.length) {
|
||||||
|
@ -177,7 +155,7 @@ function main() {
|
||||||
// replace the default unexpected error handler to be useful during tests
|
// replace the default unexpected error handler to be useful during tests
|
||||||
loader(['vs/base/common/errors'], function (errors) {
|
loader(['vs/base/common/errors'], function (errors) {
|
||||||
errors.setUnexpectedErrorHandler(function (err) {
|
errors.setUnexpectedErrorHandler(function (err) {
|
||||||
let stack = (err && err.stack) || (new Error().stack);
|
const stack = (err && err.stack) || (new Error().stack);
|
||||||
unexpectedErrors.push((err && err.message ? err.message : err) + '\n' + stack);
|
unexpectedErrors.push((err && err.message ? err.message : err) + '\n' + stack);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -188,7 +166,7 @@ function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv.some(function (a) { return /^--browser/.test(a); })) {
|
if (process.argv.some(function (a) { return /^--browser/.test(a); })) {
|
||||||
require('./browser');
|
require('../../browser');
|
||||||
} else {
|
} else {
|
||||||
main();
|
main();
|
||||||
}
|
}
|
Loading…
Reference in a new issue