Skip to content

Commit 0cffa4e

Browse files
authored
Dev/waan/fix test run (#3581)
* Fix integration tests and fail if tests fail
1 parent b67e701 commit 0cffa4e

17 files changed

Lines changed: 102 additions & 64 deletions

File tree

Extension/.vscode/launch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
"args": [
4848
"${workspaceFolder}/test/integrationTests/testAssets/SimpleCppProject",
4949
"--extensionDevelopmentPath=${workspaceFolder}",
50-
"--extensionTestsPath=${workspaceFolder}/out/test/integrationTests"
50+
"--extensionTestsPath=${workspaceFolder}/out/test/integrationTests/languageServer"
5151
],
5252
"stopOnEntry": false,
5353
"sourceMaps": true,
5454
"outFiles": [
5555
"${workspaceFolder}/out/test/**/*.js"
56-
]
56+
],
57+
"preLaunchTask": "Pretest"
5758
},
5859
]
5960
}

Extension/.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@
6868
"TypeScript Compile"
6969
],
7070
"problemMatcher": "$tsc-watch"
71+
},
72+
{
73+
"label": "Pretest",
74+
"group": "build",
75+
"isBackground": false,
76+
"type": "shell",
77+
"command": "npm",
78+
"args": [
79+
"run",
80+
"pretest"
81+
],
82+
"dependsOn": [
83+
"TypeScript Compile"
84+
],
85+
"problemMatcher": "$tsc-watch"
7186
}
7287
]
7388
}

Extension/gulpfile.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,6 @@ gulp.task('unitTests', (done) => {
2929
});
3030
});
3131

32-
gulp.task('integrationTests', (done) => {
33-
env.set({
34-
CODE_TESTS_PATH: "./out/test/integrationTests",
35-
CODE_TESTS_WORKSPACE: "./test/integrationTests/testAssets/SimpleCppProject"
36-
});
37-
38-
return gulp.src('./test/runVsCodeTestsWithAbsolutePaths.js', {read: false})
39-
.pipe(mocha({ ui: "tdd" }))
40-
.once('error', err => {
41-
done();
42-
process.exit(1);
43-
})
44-
.once('end', () => {
45-
done();
46-
process.exit();
47-
});
48-
});
49-
5032
/// Misc Tasks
5133
const allTypeScript = [
5234
'src/**/*.ts',

Extension/jobs/build.windows.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- script: npm install
1717
displayName: "Install Dependencies"
1818
workingDirectory: '$(Build.SourcesDirectory)\Extension'
19-
19+
2020
- script: npm run compile
2121
displayName: "Compile Sources"
2222
workingDirectory: '$(Build.SourcesDirectory)\Extension'
@@ -34,10 +34,13 @@ jobs:
3434
workingDirectory: '$(Build.SourcesDirectory)\Extension'
3535
continueOnError: true
3636

37+
- script: npm run pretest
38+
displayName: "Compile Test Sources"
39+
workingDirectory: '$(Build.SourcesDirectory)\Extension'
40+
3741
- script: 'node node_modules/vscode/bin/test'
3842
displayName: 'Run languageServer integration tests'
3943
workingDirectory: '$(Build.SourcesDirectory)\Extension'
40-
continueOnError: true
4144
env:
4245
CODE_TESTS_PATH: '$(Build.SourcesDirectory)\Extension\out\test\integrationTests\languageServer'
4346
CODE_EXTENSIONS_PATH: '$(Build.SourcesDirectory)\Extension'

Extension/jobs/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- script: npm install
1616
displayName: "Install Dependencies"
1717
workingDirectory: '$(Build.SourcesDirectory)/Extension'
18-
18+
1919
- script: npm run compile
2020
displayName: "Compile Sources"
2121
workingDirectory: '$(Build.SourcesDirectory)/Extension'
@@ -39,10 +39,13 @@ jobs:
3939
disown -ar
4040
displayName: 'Start xvfb'
4141
42+
- script: npm run pretest
43+
displayName: "Compile Test Sources"
44+
workingDirectory: '$(Build.SourcesDirectory)/Extension'
45+
4246
- script: 'node node_modules/vscode/bin/test'
4347
displayName: 'Run languageServer integration tests'
4448
workingDirectory: '$(Build.SourcesDirectory)/Extension'
45-
continueOnError: true
4649
env:
4750
DISPLAY: :10
4851
CODE_TESTS_PATH: '$(Build.SourcesDirectory)/Extension/out/test/integrationTests/languageServer'

Extension/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,11 +1440,9 @@
14401440
"compile": "npm run vscode:prepublish",
14411441
"compileDev": "webpack --mode development",
14421442
"generateOptionsSchema": "gulp generateOptionsSchema",
1443-
"integrationTests": "gulp integrationTests",
14441443
"postinstall": "node ./node_modules/vscode/bin/install",
1445-
"pretest": "tsc -p ./",
1444+
"pretest": "tsc -p test.tsconfig.json",
14461445
"pr-check": "gulp pr-check",
1447-
"test": "gulp allTests",
14481446
"tslint": "gulp tslint",
14491447
"unitTests": "gulp unitTests",
14501448
"vscode:prepublish": "node ./tools/prepublish.js && webpack --mode production",
@@ -1653,4 +1651,4 @@
16531651
"binaries": []
16541652
}
16551653
]
1656-
}
1654+
}

Extension/src/LanguageServer/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ class DefaultClient implements Client {
413413
let settings: CppSettings = new CppSettings(workspaceFolder ? workspaceFolder.uri : null);
414414
let other: OtherSettings = new OtherSettings(workspaceFolder ? workspaceFolder.uri : null);
415415

416-
let storagePath: string = util.extensionContext.storagePath;
416+
let storagePath: string = util.extensionContext ? util.extensionContext.storagePath :
417+
path.join((workspaceFolder ? workspaceFolder.uri.fsPath : ""), "/.vscode");
417418
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) {
418419
storagePath = path.join(storagePath, serverName);
419420
}
@@ -445,7 +446,7 @@ class DefaultClient implements Client {
445446
clang_format_fallbackStyle: settings.clangFormatFallbackStyle,
446447
clang_format_sortIncludes: settings.clangFormatSortIncludes,
447448
formatting: settings.formatting,
448-
extension_path: util.extensionContext.extensionPath,
449+
extension_path: util.extensionPath,
449450
exclude_files: other.filesExclude,
450451
exclude_search: other.searchExclude,
451452
storage_path: storagePath,

Extension/src/LanguageServer/persistentState.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ class PersistentStateBase<T> {
1212
private key: string;
1313
private defaultvalue: T;
1414
private state: vscode.Memento;
15+
private curvalue: T;
1516

1617
constructor(key: string, defaultValue: T, state: vscode.Memento) {
1718
this.key = key;
1819
this.defaultvalue = defaultValue;
1920
this.state = state;
21+
this.curvalue = defaultValue;
2022
}
2123

2224
public get Value(): T {
23-
return this.state.get<T>(this.key, this.defaultvalue);
25+
return this.state ? this.state.get<T>(this.key, this.defaultvalue) : this.curvalue;
2426
}
2527

2628
public set Value(newValue: T) {
27-
this.state.update(this.key, newValue);
29+
if (this.state) {
30+
this.state.update(this.key, newValue);
31+
}
32+
this.curvalue = newValue;
2833
}
2934

3035
public get DefaultValue(): T {
@@ -35,13 +40,13 @@ class PersistentStateBase<T> {
3540
// Abstraction for global state that persists across activations but is not present in a settings file
3641
export class PersistentState<T> extends PersistentStateBase<T> {
3742
constructor(key: string, defaultValue: T) {
38-
super(key, defaultValue, util.extensionContext.globalState);
43+
super(key, defaultValue, util.extensionContext ? util.extensionContext.globalState : null);
3944
}
4045
}
4146

4247
export class PersistentWorkspaceState<T> extends PersistentStateBase<T> {
4348
constructor(key: string, defaultValue: T) {
44-
super(key, defaultValue, util.extensionContext.workspaceState);
49+
super(key, defaultValue, util.extensionContext ? util.extensionContext.workspaceState : null);
4550
}
4651
}
4752

Extension/src/LanguageServer/settingsPanel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ export class SettingsPanel {
6262

6363
// Restrict the webview to only loading content from these directories
6464
localResourceRoots: [
65-
vscode.Uri.file(util.extensionContext.extensionPath),
66-
vscode.Uri.file(path.join(util.extensionContext.extensionPath, 'ui')),
67-
vscode.Uri.file(path.join(util.extensionContext.extensionPath, 'out', 'ui'))]
65+
vscode.Uri.file(util.extensionPath),
66+
vscode.Uri.file(path.join(util.extensionPath, 'ui')),
67+
vscode.Uri.file(path.join(util.extensionPath, 'out', 'ui'))]
6868
}
6969
);
7070

@@ -201,7 +201,7 @@ export class SettingsPanel {
201201

202202
content = content.replace(
203203
/{{root}}/g,
204-
vscode.Uri.file(util.extensionContext.extensionPath)
204+
vscode.Uri.file(util.extensionPath)
205205
.with({ scheme: 'vscode-resource' })
206206
.toString());
207207

Extension/src/commands.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import * as vscode from 'vscode';
88
import * as LanguageServer from './LanguageServer/extension';
9+
import * as util from './common';
910

1011
class TemporaryCommandRegistrar {
1112
// Used to save/re-execute commands used before the extension has activated (e.g. delayed by dependency downloading).
@@ -41,9 +42,11 @@ class TemporaryCommandRegistrar {
4142
this.delayedCommandsToExecute = new Set<string>();
4243

4344
// Add temp commands that invoke the real commands after download/install is complete (preventing an error message)
44-
this.commandsToRegister.forEach(command => {
45-
this.registerTempCommand(command);
46-
});
45+
if (util.extensionContext) {
46+
this.commandsToRegister.forEach(command => {
47+
this.registerTempCommand(command);
48+
});
49+
}
4750
}
4851

4952
public registerTempCommand(command: string): void {

0 commit comments

Comments
 (0)