Skip to content

Commit 5e89352

Browse files
authored
Migrarion to @types/vscode and vscode-test (#1126)
Fix #1058. This fix includes: 1. Update fot vscode engine version. 2. Migration from vscode modulet to @types/vscode and vscode-test 3. unit-tests.ts script to run unit-tests 4. Unit and integration tests separation 5. Move coverage to independent module 6. Fix unit-tests for vscode 1.38.0 7. Fix git command to check changed files
1 parent d51a983 commit 5e89352

38 files changed

+331
-358
lines changed

.vscode/launch.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"runtimeExecutable": "${execPath}",
2727
"args": [
2828
"--extensionDevelopmentPath=${workspaceFolder}",
29-
"--extensionTestsPath=${workspaceFolder}/out/test"
29+
"--extensionTestsPath=${workspaceFolder}/out/test/unit"
3030
],
3131
"outFiles": [
32-
"${workspaceFolder}/out/test/**/*.js"
32+
"${workspaceFolder}/out/test/unit/**/*.js"
3333
],
3434
"preLaunchTask": "npm: watch",
3535
"env": {
@@ -43,15 +43,32 @@
4343
"runtimeExecutable": "${execPath}",
4444
"args": [
4545
"--extensionDevelopmentPath=${workspaceFolder}",
46-
"--extensionTestsPath=${workspaceFolder}/out/test"
46+
"--extensionTestsPath=${workspaceFolder}/out/test/unit"
4747
],
4848
"outFiles": [
49-
"${workspaceFolder}/out/test/**/*.js"
49+
"${workspaceFolder}/out/test/unit/**/*.js"
5050
],
5151
"preLaunchTask": "npm: watch",
5252
"env": {
5353
"VSCOST_TEST_MODE": "coverage"
5454
}
55+
},
56+
{
57+
"name": "Extension integration Tests Debug",
58+
"type": "extensionHost",
59+
"request": "launch",
60+
"runtimeExecutable": "${execPath}",
61+
"args": [
62+
"--extensionDevelopmentPath=${workspaceFolder}",
63+
"--extensionTestsPath=${workspaceFolder}/out/test/int"
64+
],
65+
"outFiles": [
66+
"${workspaceFolder}/out/test/int/**/*.js"
67+
],
68+
"preLaunchTask": "npm: watch",
69+
"env": {
70+
"VSCOST_TEST_MODE": "debug"
71+
}
5572
}
5673
]
5774
}

build/unit-tests.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as path from 'path';
2+
3+
import { runTests } from 'vscode-test';
4+
5+
async function main() {
6+
try {
7+
// The folder containing the Extension Manifest package.json
8+
// Passed to `--extensionDevelopmentPath`
9+
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10+
11+
// The path to the extension test runner script
12+
// Passed to --extensionTestsPath
13+
const extensionTestsPath = path.resolve(__dirname, '../../out/test/unit/');
14+
15+
// Download VS Code, unzip it and run the integration test
16+
console.log(extensionDevelopmentPath, extensionTestsPath);
17+
await runTests({ extensionDevelopmentPath, extensionTestsPath });
18+
} catch (err) {
19+
console.error(err);
20+
process.exit(1);
21+
}
22+
}
23+
24+
main();

build/verify-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function downloadFileAndCreateSha256(targetFolder: string, fileName: strin
3939
}
4040

4141
const fileCheckRegex = /\w*tools.json/;
42-
cp.exec('git diff --name-only master..HEAD', async (error, stdout, stderr) => {
42+
cp.exec('git diff --name-only origin/master -- .', async (error, stdout, stderr) => {
4343
if (error) {
4444
throw error;
4545
}

coverconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"enabled": true,
3-
"relativeSourcePath": "../src",
3+
"relativeSourcePath": "../../src",
44
"relativeCoverageDir": "../../coverage",
55
"ignorePatterns": [
66
"**/node_modules/**"

package-lock.json

Lines changed: 14 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,8 @@
893893
"vscode:prepublish": "npm run build",
894894
"compile": "tsc -p ./",
895895
"watch": "tsc -watch -p ./",
896-
"postinstall": "node ./node_modules/vscode/bin/install",
897896
"clean": "rm -rf out || rmdir out /s /q",
898-
"test": "npm run clean && npm run compile && npm run verify && node ./node_modules/vscode/bin/test",
897+
"test": "npm run clean && npm run compile && npm run verify && node ./out/build/unit-tests.js",
899898
"update-deps": "node_modules/.bin/ncu --upgrade --loglevel verbose --packageFile package.json && npm update",
900899
"coverage:upload": "codecov -f coverage/coverage-final.json",
901900
"build": "npm run clean && tslint -p tslint.json && npm run compile"
@@ -916,6 +915,7 @@
916915
"@types/string-format": "^2.0.0",
917916
"@types/tmp": "0.1.0",
918917
"@types/validator": "^10.11.2",
918+
"@types/vscode": "^1.30.0",
919919
"chai": "^4.2.0",
920920
"codecov": "^3.5.0",
921921
"decache": "^4.5.1",
@@ -930,7 +930,7 @@
930930
"tmp": "0.1.0",
931931
"tslint": "^5.19.0",
932932
"typescript": "^3.6.2",
933-
"vscode": "^1.1.36",
933+
"vscode-test": "^1.2.0",
934934
"walker": "^1.0.7"
935935
},
936936
"dependencies": {

src/odo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class OdoModel {
489489
return Array.from(this.contextToSettings.values());
490490
}
491491

492-
public addContexts(folders: WorkspaceFolder[]) {
492+
public addContexts(folders: ReadonlyArray<WorkspaceFolder>) {
493493
for (const folder of folders) {
494494
try {
495495
const compData = yaml.safeLoad(fs.readFileSync(path.join(folder.uri.fsPath, '.odo', 'config.yaml'), 'utf8')) as odo.Config;

0 commit comments

Comments
 (0)