Cleanup dependencies (#195026)

* move build dependencies to devDependencies

* build: bump tree-sitter

* dependencies cleanup

* remove leftover file
This commit is contained in:
João Moreno
2023-10-09 08:34:15 +01:00
committed by GitHub
parent 55d1cfea45
commit a5d71aad39
15 changed files with 382 additions and 903 deletions

View File

@@ -15,14 +15,40 @@ const fs = require('fs');
const glob = require('glob');
const minimatch = require('minimatch');
const coverage = require('../coverage');
const optimist = require('optimist')
.usage('Run the Code tests. All mocha options apply.')
.describe('build', 'Run from out-build').boolean('build')
.describe('run', 'Run a single file').string('run')
.describe('coverage', 'Generate a coverage report').boolean('coverage')
.alias('h', 'help').boolean('h')
.describe('h', 'Show help');
const minimist = require('minimist');
/**
* @type {{ build: boolean; run: string; runGlob: string; coverage: boolean; help: boolean; }}
*/
const args = minimist(process.argv.slice(2), {
boolean: ['build', 'coverage', 'help'],
string: ['run'],
alias: {
h: 'help'
},
default: {
build: false,
coverage: false,
help: false
},
description: {
build: 'Run from out-build',
run: 'Run a single file',
coverage: 'Generate a coverage report',
help: 'Show help'
}
});
if (args.help) {
console.log(`Usage: node test/unit/node/index [options]
Options:
--build Run from out-build
--run <file> Run a single file
--coverage Generate a coverage report
--help Show help`);
process.exit(0);
}
const TEST_GLOB = '**/test/**/*.test.js';
@@ -33,21 +59,12 @@ const excludeGlobs = [
'**/vs/workbench/contrib/testing/test/**' // flaky (https://github.com/microsoft/vscode/issues/137853)
];
/**
* @type {{ build: boolean; run: string; runGlob: string; coverage: boolean; help: boolean; }}
*/
const argv = optimist.argv;
if (argv.help) {
optimist.showHelp();
process.exit(1);
}
const REPO_ROOT = path.join(__dirname, '../../../');
const out = argv.build ? 'out-build' : 'out';
const out = args.build ? 'out-build' : 'out';
const loader = require(`../../../${out}/vs/loader`);
const src = path.join(REPO_ROOT, out);
//@ts-ignore
const majorRequiredNodeVersion = `v${/^target\s+"([^"]+)"$/m.exec(fs.readFileSync(path.join(REPO_ROOT, 'remote', '.yarnrc'), 'utf8'))[1]}`.substring(0, 3);
const currentMajorNodeVersion = process.version.substring(0, 3);
if (majorRequiredNodeVersion !== currentMajorNodeVersion) {
@@ -115,14 +132,14 @@ function main() {
catchError: true
};
if (argv.coverage) {
if (args.coverage) {
coverage.initialize(loaderConfig);
process.on('exit', function (code) {
if (code !== 0) {
return;
}
coverage.createReport(argv.run || argv.runGlob);
coverage.createReport(args.run || args.runGlob);
});
}
@@ -155,7 +172,7 @@ function main() {
/** @type { null|((callback:(err:any)=>void)=>void) } */
let loadFunc = null;
if (argv.runGlob) {
if (args.runGlob) {
loadFunc = (cb) => {
const doRun = /** @param {string[]} tests */(tests) => {
const modulesToLoad = tests.map(test => {
@@ -168,10 +185,10 @@ function main() {
loadModules(modulesToLoad).then(() => cb(null), cb);
};
glob(argv.runGlob, { cwd: src }, function (err, files) { doRun(files); });
glob(args.runGlob, { cwd: src }, function (err, files) { doRun(files); });
};
} else if (argv.run) {
const tests = (typeof argv.run === 'string') ? [argv.run] : argv.run;
} else if (args.run) {
const tests = (typeof args.run === 'string') ? [args.run] : args.run;
const modulesToLoad = tests.map(function (test) {
test = test.replace(/^src/, 'out');
test = test.replace(/\.ts$/, '.js');
@@ -203,7 +220,7 @@ function main() {
process.stderr.write = write;
if (!argv.run && !argv.runGlob) {
if (!args.run && !args.runGlob) {
// set up last test
Mocha.suite('Loader', function () {
test('should not explode while loading', function () {