Skip to content

Commit ed2899a

Browse files
committed
Combine test compile step into normal compile
1 parent fecf024 commit ed2899a

38 files changed

+185
-192
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
"compileDev": "tsc -p ./ && tslint -p ./ && webpack --mode development",
4646
"watch": "tsc -watch -p ./",
4747
"tdd": "mocha --config ./.mocharc.jsonc --watch --watch-extensions ts test/unitTests/**/*.test.ts*",
48-
"test": "tsc -p test && gulp test",
49-
"test:unit": "tsc -p test && gulp test:unit",
50-
"test:feature": "tsc -p test && gulp test:feature",
51-
"test:integration": "tsc -p test && gulp test:integration",
52-
"test:integration:singleCsproj": "tsc -p test && gulp test:integration:singleCsproj",
53-
"test:integration:slnWithCsproj": "tsc -p test && gulp test:integration:slnWithCsproj",
54-
"test:integration:slnFilterWithCsproj": "tsc -p test && gulp test:integration:slnFilterWithCsproj",
55-
"test:release": "tsc -p test && mocha out/test/releaseTests/**/*.test.js",
56-
"test:artifacts": "tsc -p test && mocha out/test/artifactTests/**/*.test.js",
48+
"test": "tsc -p ./ && gulp test",
49+
"test:unit": "tsc -p ./ && gulp test:unit",
50+
"test:feature": "tsc -p ./ && gulp test:feature",
51+
"test:integration": "tsc -p ./ && gulp test:integration",
52+
"test:integration:singleCsproj": "tsc -p ./ && gulp test:integration:singleCsproj",
53+
"test:integration:slnWithCsproj": "tsc -p ./ && gulp test:integration:slnWithCsproj",
54+
"test:integration:slnFilterWithCsproj": "tsc -p ./ && gulp test:integration:slnFilterWithCsproj",
55+
"test:release": "tsc -p ./ && mocha out/test/releaseTests/**/*.test.js",
56+
"test:artifacts": "tsc -p ./ && mocha out/test/artifactTests/**/*.test.js",
5757
"unpackage:vsix": "gulp vsix:release:unpackage",
5858
"updatePackageDependencies": "gulp updatePackageDependencies"
5959
},

test/featureTests/assets.test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ suite("Asset generation: csproj", () => {
2424
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
2525
generator.setStartupProject(0);
2626
let tasksJson = generator.createTasksConfiguration();
27-
let buildPath = tasksJson.tasks[0].args[1];
27+
let buildPath = tasksJson.tasks![0].args![1];
2828

2929
// ${workspaceFolder}/project.json
3030
let segments = buildPath.split(path.posix.sep);
@@ -39,9 +39,9 @@ suite("Asset generation: csproj", () => {
3939
let tasksJson = generator.createTasksConfiguration();
4040

4141
// We do not check the watch task since this parameter can break hot reload scenarios.
42-
tasksJson.tasks
42+
tasksJson.tasks!
4343
.filter(task => task.label !== "watch")
44-
.forEach(task => task.args.should.contain("/property:GenerateFullPaths=true"));
44+
.forEach(task => task.args!.should.contain("/property:GenerateFullPaths=true"));
4545
});
4646

4747
test("Generated 'build' and 'publish' tasks have the consoleloggerparameters argument set to NoSummary", () => {
@@ -52,9 +52,9 @@ suite("Asset generation: csproj", () => {
5252
let tasksJson = generator.createTasksConfiguration();
5353

5454
// We do not check the watch task since this parameter can break hot reload scenarios.
55-
tasksJson.tasks
55+
tasksJson.tasks!
5656
.filter(task => task.label !== "watch")
57-
.forEach(task => task.args.should.contain("/consoleloggerparameters:NoSummary"));
57+
.forEach(task => task.args!.should.contain("/consoleloggerparameters:NoSummary"));
5858
});
5959

6060
test("Generated 'watch' task does not have the property GenerateFullPaths set to true ", () => {
@@ -64,8 +64,8 @@ suite("Asset generation: csproj", () => {
6464
generator.setStartupProject(0);
6565
let tasksJson = generator.createTasksConfiguration();
6666

67-
const watchTask = tasksJson.tasks.find(task => task.label === "watch");
68-
watchTask.args.should.not.contain("/property:GenerateFullPaths=true");
67+
const watchTask = tasksJson.tasks!.find(task => task.label === "watch");
68+
watchTask!.args!.should.not.contain("/property:GenerateFullPaths=true");
6969
});
7070

7171
test("Generated 'watch' task does not have the consoleloggerparameters argument set to NoSummary", () => {
@@ -75,8 +75,8 @@ suite("Asset generation: csproj", () => {
7575
generator.setStartupProject(0);
7676
let tasksJson = generator.createTasksConfiguration();
7777

78-
const watchTask = tasksJson.tasks.find(task => task.label === "watch");
79-
watchTask.args.should.not.contain("/consoleloggerparameters:NoSummary");
78+
const watchTask = tasksJson.tasks!.find(task => task.label === "watch");
79+
watchTask!.args!.should.not.contain("/consoleloggerparameters:NoSummary");
8080
});
8181

8282
test("Create tasks.json for nested project opened in workspace", () => {
@@ -85,7 +85,7 @@ suite("Asset generation: csproj", () => {
8585
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
8686
generator.setStartupProject(0);
8787
let tasksJson = generator.createTasksConfiguration();
88-
let buildPath = tasksJson.tasks[0].args[1];
88+
let buildPath = tasksJson.tasks![0].args![1];
8989

9090
// ${workspaceFolder}/nested/project.json
9191
let segments = buildPath.split(path.posix.sep);
@@ -100,7 +100,7 @@ suite("Asset generation: csproj", () => {
100100
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Console), undefined, { disallowComments: true });
101101
let programPath: string = launchJson[0].program;
102102

103-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
103+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
104104
});
105105

106106
[5, 6, 7, 8, 9].forEach(version => {
@@ -114,7 +114,7 @@ suite("Asset generation: csproj", () => {
114114
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Console), undefined, { disallowComments: true });
115115
let programPath: string = launchJson[0].program;
116116

117-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
117+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
118118
});
119119
});
120120

@@ -126,7 +126,7 @@ suite("Asset generation: csproj", () => {
126126
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Console), undefined, { disallowComments: true });
127127
let programPath: string = launchJson[0].program;
128128

129-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
129+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
130130
});
131131

132132
test("Create launch.json for project opened in workspace with non-relative output path", function() {
@@ -142,7 +142,7 @@ suite("Asset generation: csproj", () => {
142142
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Console), undefined, { disallowComments: true });
143143
let programPath: string = launchJson[0].program;
144144

145-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
145+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
146146
});
147147

148148
test("Create launch.json for Blazor web assembly standalone project opened in workspace", () => {
@@ -180,7 +180,7 @@ suite("Asset generation: csproj", () => {
180180
const cwd = hostedBlazorLaunchConfig.cwd;
181181
const hosted = hostedBlazorLaunchConfig.hosted;
182182

183-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
183+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
184184

185185
cwd.should.equal('${workspaceFolder}');
186186
hosted.should.equal(true);
@@ -197,7 +197,7 @@ suite("Asset generation: csproj", () => {
197197
const cwd = hostedBlazorLaunchConfig.cwd;
198198
const hosted = hostedBlazorLaunchConfig.hosted;
199199

200-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
200+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
201201

202202
cwd.should.equal('${workspaceFolder}/nested');
203203
hosted.should.equal(true);
@@ -211,7 +211,7 @@ suite("Asset generation: csproj", () => {
211211
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Web), undefined, { disallowComments: true });
212212
let programPath: string = launchJson[0].program;
213213

214-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
214+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
215215
});
216216

217217
test("Create launch.json for nested web project opened in workspace", () => {
@@ -222,7 +222,7 @@ suite("Asset generation: csproj", () => {
222222
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Web), undefined, { disallowComments: true });
223223
let programPath: string = launchJson[0].program;
224224

225-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
225+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
226226
});
227227

228228
test("Add a new item to JSON", () => {
@@ -234,7 +234,7 @@ suite("Asset generation: csproj", () => {
234234
};
235235

236236
const newItem = { name: 'new-item' };
237-
const updated = updateJsonWithComments(JSON.stringify(original), [newItem], 'configurations', 'name', /*formattingOptions*/ null);
237+
const updated = updateJsonWithComments(JSON.stringify(original), [newItem], 'configurations', 'name', /*formattingOptions*/ null!);
238238
const parsed = jsonc.parse(updated);
239239
const configurations = parsed.configurations;
240240

@@ -254,7 +254,7 @@ suite("Asset generation: csproj", () => {
254254

255255
const updatedItem = { name: 'build', command: 'dotnet' };
256256

257-
const updated = updateJsonWithComments(JSON.stringify(original), [updatedItem], 'configurations', 'name', /*formattingOptions*/ null);
257+
const updated = updateJsonWithComments(JSON.stringify(original), [updatedItem], 'configurations', 'name', /*formattingOptions*/ null!);
258258
const parsed = jsonc.parse(updated);
259259
const configurations = parsed.configurations;
260260

@@ -278,7 +278,7 @@ suite("Asset generation: csproj", () => {
278278

279279
const updatedItem = { name: 'build', command: 'dotnet' };
280280

281-
const updated = updateJsonWithComments(original, [updatedItem], 'configurations', 'name', /*formattingOptions*/ null);
281+
const updated = updateJsonWithComments(original, [updatedItem], 'configurations', 'name', /*formattingOptions*/ null!);
282282
const lines = updated.trim().split('\n');
283283

284284
lines[0].trim().should.equal('// user comment in file');
@@ -336,12 +336,12 @@ function checkProgramPath(rootPath: string, programPath: string, targetPath: str
336336
function createMockWorkspaceFolder(rootPath: string): vscode.WorkspaceFolder {
337337
return {
338338
uri: vscode.Uri.file(rootPath),
339-
name: undefined,
340-
index: undefined
339+
name: '',
340+
index: -1
341341
};
342342
}
343343

344-
function createMSBuildWorkspaceInformation(projectPath: string, assemblyName: string, targetFrameworkShortName: string, targetPath: string = undefined, isExe: boolean = true, isWebProject: boolean = false, isBlazorWebAssemblyStandalone: boolean = false, isBlazorWebAssemblyHosted: boolean = false): protocol.WorkspaceInformationResponse {
344+
function createMSBuildWorkspaceInformation(projectPath: string, assemblyName: string, targetFrameworkShortName: string, targetPath: string | undefined = undefined, isExe: boolean = true, isWebProject: boolean = false, isBlazorWebAssemblyStandalone: boolean = false, isBlazorWebAssemblyHosted: boolean = false): protocol.WorkspaceInformationResponse {
345345
return {
346346
MsBuild: {
347347
SolutionPath: '',

test/featureTests/processPicker.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ suite("Remote Process Picker: Validate quoting arguments.", () => {
197197
process1.name.should.equal('System Idle Process');
198198
process1.pid.should.equal('0');
199199

200-
process2.commandLine.should.equal('"C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.12.2931.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"');
200+
process2.commandLine!.should.equal('"C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_1.12.2931.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"');
201201
process2.name.should.equal('WindowsTerminal.exe');
202202
process2.pid.should.equal('5112');
203203

204-
process3.commandLine.should.equal('C:\\WINDOWS\\system32\\conhost.exe --headless --width 80 --height 30 --signal 0x8e0 --server 0x824');
204+
process3.commandLine!.should.equal('C:\\WINDOWS\\system32\\conhost.exe --headless --width 80 --height 30 --signal 0x8e0 --server 0x824');
205205
process3.name.should.equal('conhost.exe');
206206
process3.pid.should.equal('34560');
207207

208-
process4.commandLine.should.equal('C:\\WINDOWS\\system32\\conhost.exe 0x4');
208+
process4.commandLine!.should.equal('C:\\WINDOWS\\system32\\conhost.exe 0x4');
209209
process4.name.should.equal('conhost.exe');
210210
process4.pid.should.equal('33732');
211211
});

test/integrationTests/advisor.integration.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ suite(`Advisor ${testAssetWorkspace.description}`, function () {
3434
const activation = await activateCSharpExtension();
3535
await testAssetWorkspace.restore();
3636

37-
if (!activation) {
38-
throw new Error('Cannot activate extension.');
39-
} else {
40-
advisor = activation.advisor;
41-
}
37+
advisor = activation.advisor;
4238

4339
let fileName = 'completion.cs';
4440
let dir = testAssetWorkspace.projects[0].projectDirectoryPath;

test/integrationTests/codeActionRename.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ suite(`Code Action Rename ${testAssetWorkspace.description}`, function () {
4444
const codeAction = codeActions.find(codeAction => codeAction.title == "Rename file to C.cs");
4545
expect(codeAction, "Didn't find rename class code action");
4646

47-
await vscode.commands.executeCommand(codeAction.command.command, ...codeAction.command.arguments);
47+
await vscode.commands.executeCommand(codeAction!.command!.command, ...codeAction!.command!.arguments!);
4848

49-
await assertWithPoll(() => { }, 15 * 1000, 500, _ => expect(vscode.window.activeTextEditor.document.fileName).contains("C.cs"));
49+
await assertWithPoll(() => { }, 15 * 1000, 500, _ => expect(vscode.window.activeTextEditor!.document.fileName).contains("C.cs"));
5050
});
5151
});

test/integrationTests/codeLensProvider.integration.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ suite(`CodeLensProvider: ${testAssetWorkspace.description}`, function () {
6161
for (let codeLens of codeLenses) {
6262
expect(codeLens.isResolved).to.be.true;
6363
expect(codeLens.command).not.to.be.undefined;
64-
expect(codeLens.command.title).to.equal("0 references");
64+
expect(codeLens.command!.title).to.equal("0 references");
6565
}
6666
});
6767
});
@@ -105,8 +105,8 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()
105105
for (let codeLens of codeLenses) {
106106
expect(codeLens.isResolved).to.be.true;
107107
expect(codeLens.command).not.to.be.undefined;
108-
expect(codeLens.command.command).to.be.oneOf(['dotnet.test.run', 'dotnet.classTests.run', 'dotnet.test.debug', 'dotnet.classTests.debug']);
109-
expect(codeLens.command.title).to.be.oneOf(['Run Test', 'Run All Tests', 'Debug Test', 'Debug All Tests']);
108+
expect(codeLens.command!.command).to.be.oneOf(['dotnet.test.run', 'dotnet.classTests.run', 'dotnet.test.debug', 'dotnet.classTests.debug']);
109+
expect(codeLens.command!.title).to.be.oneOf(['Run Test', 'Run All Tests', 'Debug Test', 'Debug All Tests']);
110110
}
111111
});
112112

@@ -121,8 +121,8 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()
121121
for (let codeLens of codeLenses) {
122122
expect(codeLens.isResolved).to.be.true;
123123
expect(codeLens.command).not.to.be.undefined;
124-
expect(codeLens.command.command).to.be.equal('editor.action.showReferences');
125-
expect(codeLens.command.title).to.equal('0 references');
124+
expect(codeLens.command!.command).to.be.equal('editor.action.showReferences');
125+
expect(codeLens.command!.title).to.equal('0 references');
126126
}
127127
});
128128

test/integrationTests/diagnostics.integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
116116

117117
let cs0219 = result.find(x => x.code === "CS0219");
118118
expect(cs0219).to.not.be.undefined;
119-
expect(cs0219.tags).to.include(vscode.DiagnosticTag.Unnecessary);
119+
expect(cs0219!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
120120
});
121121

122122
test("Return unnecessary tag in case of unnesessary using", async function () {
@@ -128,7 +128,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
128128

129129
let cs8019 = result.find(x => x.code === "CS8019");
130130
expect(cs8019).to.not.be.undefined;
131-
expect(cs8019.tags).to.include(vscode.DiagnosticTag.Unnecessary);
131+
expect(cs8019!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
132132
});
133133

134134
test("Return fadeout diagnostics like unused variables based on roslyn analyzers", async function () {
@@ -140,7 +140,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
140140

141141
let ide0059 = result.find(x => x.code === "IDE0059");
142142
expect(ide0059).to.not.be.undefined;
143-
expect(ide0059.tags).to.include(vscode.DiagnosticTag.Unnecessary);
143+
expect(ide0059!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
144144
});
145145

146146
test("On small workspaces also show/fetch closed document analysis results", async function () {

test/integrationTests/dotnetTest.integration.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ suite(`DotnetTest: ${testAssetWorkspace.description}`, function () {
5959
await vscode.commands.executeCommand('dotnet.test.runTestsInContext');
6060

6161
const event = await eventWaiter;
62-
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
62+
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;
6363

6464
expect(runTestsRequest.RunSettings).to.be.undefined;
6565
});
@@ -76,7 +76,7 @@ suite(`DotnetTest: ${testAssetWorkspace.description}`, function () {
7676
await vscode.commands.executeCommand('dotnet.test.runTestsInContext');
7777

7878
const event = await eventWaiter;
79-
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
79+
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;
8080

8181
expect(runTestsRequest.RunSettings).to.be.equal(absoluteRunSettingsPath);
8282
});
@@ -93,11 +93,11 @@ suite(`DotnetTest: ${testAssetWorkspace.description}`, function () {
9393
await vscode.commands.executeCommand('dotnet.test.runTestsInContext');
9494

9595
const event = await eventWaiter;
96-
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
96+
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;
9797

9898
expect(runTestsRequest.RunSettings).to.be.not.null;
99-
expect(runTestsRequest.RunSettings.endsWith(endingPath), "Path includes relative path").to.be.true;
100-
expect(path.isAbsolute(runTestsRequest.RunSettings), "Path is absolute").to.be.true;
99+
expect(runTestsRequest.RunSettings!.endsWith(endingPath), "Path includes relative path").to.be.true;
100+
expect(path.isAbsolute(runTestsRequest.RunSettings!), "Path is absolute").to.be.true;
101101
});
102102
});
103103

test/integrationTests/inlayHints.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ suite(`Inlay Hints ${testAssetWorkspace.description}`, function () {
8282
return;
8383
}
8484

85-
assert.equal(actual.textEdits.length, expected.TextEdits.length);
85+
assert.equal(actual.textEdits.length, expected.TextEdits!.length);
8686
for (let i = 0; i < actual.textEdits.length; i++) {
8787
const actualTextEdit = actual.textEdits[i];
88-
const expectedTextEdit = expected.TextEdits[i];
88+
const expectedTextEdit = expected.TextEdits![i];
8989

9090
assertTextEditEqual(actualTextEdit, expectedTextEdit);
9191
}

0 commit comments

Comments
 (0)