forked from OSchip/llvm-project
[clangd][vscode] Get rid of the deprecated vscode module in the extension.
Summary: The vscode module has been deprecated, and it doesn't work anymore after we require the minimal VSCode version 1.41.0, this patch migrate to the new @type/vscode and vscode-test modules, see https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode Reviewers: sammccall Subscribers: dschuff, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73624
This commit is contained in:
parent
a156a0e28d
commit
9b71ec899a
File diff suppressed because it is too large
Load Diff
|
@ -32,9 +32,8 @@
|
|||
"scripts": {
|
||||
"vscode:prepublish": "tsc -p ./",
|
||||
"compile": "tsc -watch -p ./",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
|
||||
"test": "node ./node_modules/vscode/bin/test",
|
||||
"test": "tsc -p ./ && node ./out/test/runTest.js",
|
||||
"package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/",
|
||||
"publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/"
|
||||
},
|
||||
|
@ -45,12 +44,15 @@
|
|||
"vscode-languageserver-types": "^3.15.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/mocha": "^2.2.32",
|
||||
"@types/node": "^6.0.40",
|
||||
"@types/vscode": "^1.41.0",
|
||||
"glob": "^7.1.4",
|
||||
"clang-format": "1.2.4",
|
||||
"mocha": "^5.2.0",
|
||||
"typescript": "^2.0.3",
|
||||
"vscode": "^1.1.0"
|
||||
"typescript": "^3.5.1",
|
||||
"vscode-test": "^1.3.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "svn",
|
||||
|
|
|
@ -1,25 +1,35 @@
|
|||
//
|
||||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
|
||||
//
|
||||
// This file is providing the test runner to use when running extension tests.
|
||||
// By default the test runner in use is Mocha based.
|
||||
//
|
||||
// You can provide your own test runner if you want to override it by exporting
|
||||
// a function run(testRoot: string, clb: (error:Error) => void) that the
|
||||
// extension host can call to run the tests. The test runner is expected to use
|
||||
// console.log to report the results back to the caller. When the tests are
|
||||
// finished, return a possible error to the callback or null if none.
|
||||
import * as glob from 'glob';
|
||||
import * as Mocha from 'mocha';
|
||||
import * as path from 'path';
|
||||
|
||||
var testRunner = require('vscode/lib/testrunner');
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
const mocha = new Mocha({ui : 'tdd'});
|
||||
mocha.useColors(true);
|
||||
|
||||
// You can directly control Mocha options by uncommenting the following lines
|
||||
// See
|
||||
// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
|
||||
// for more info
|
||||
testRunner.configure({
|
||||
ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
|
||||
// etc.)
|
||||
useColors : true // colored output from test results
|
||||
});
|
||||
const testsRoot = path.resolve(__dirname, '..');
|
||||
|
||||
module.exports = testRunner;
|
||||
return new Promise((c, e) => {
|
||||
glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
|
||||
if (err) {
|
||||
return e(err);
|
||||
}
|
||||
|
||||
// Add files to the test suite
|
||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
} else {
|
||||
c();
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
e(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import * as path from 'path';
|
||||
|
||||
import {runTests} from 'vscode-test';
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../');
|
||||
|
||||
// The path to the extension test script
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({extensionDevelopmentPath, extensionTestsPath});
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in New Issue