Skip to content

Commit f267b16

Browse files
authored
Merge pull request #5666 from dibarbet/dev/dibarbet/compile_tests
Combine test compile step into normal compile
2 parents fecf024 + 36f342b commit f267b16

39 files changed

+193
-164
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: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as jsonc from 'jsonc-parser';
1212
import { AssetGenerator, ProgramLaunchType, replaceCommentPropertiesWithComments, updateJsonWithComments } from '../../src/assets';
1313
import { parse } from 'jsonc-parser';
1414
import { use as chaiUse, should } from 'chai';
15+
import { isNotNull } from '../testUtil';
1516

1617
chaiUse(require('chai-string'));
1718

@@ -24,6 +25,8 @@ suite("Asset generation: csproj", () => {
2425
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
2526
generator.setStartupProject(0);
2627
let tasksJson = generator.createTasksConfiguration();
28+
isNotNull(tasksJson.tasks);
29+
isNotNull(tasksJson.tasks[0].args);
2730
let buildPath = tasksJson.tasks[0].args[1];
2831

2932
// ${workspaceFolder}/project.json
@@ -37,11 +40,12 @@ suite("Asset generation: csproj", () => {
3740
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
3841
generator.setStartupProject(0);
3942
let tasksJson = generator.createTasksConfiguration();
43+
isNotNull(tasksJson.tasks);
4044

4145
// We do not check the watch task since this parameter can break hot reload scenarios.
4246
tasksJson.tasks
4347
.filter(task => task.label !== "watch")
44-
.forEach(task => task.args.should.contain("/property:GenerateFullPaths=true"));
48+
.forEach(task => task.args!.should.contain("/property:GenerateFullPaths=true"));
4549
});
4650

4751
test("Generated 'build' and 'publish' tasks have the consoleloggerparameters argument set to NoSummary", () => {
@@ -50,11 +54,12 @@ suite("Asset generation: csproj", () => {
5054
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
5155
generator.setStartupProject(0);
5256
let tasksJson = generator.createTasksConfiguration();
57+
isNotNull(tasksJson.tasks);
5358

5459
// We do not check the watch task since this parameter can break hot reload scenarios.
5560
tasksJson.tasks
5661
.filter(task => task.label !== "watch")
57-
.forEach(task => task.args.should.contain("/consoleloggerparameters:NoSummary"));
62+
.forEach(task => task.args!.should.contain("/consoleloggerparameters:NoSummary"));
5863
});
5964

6065
test("Generated 'watch' task does not have the property GenerateFullPaths set to true ", () => {
@@ -63,8 +68,10 @@ suite("Asset generation: csproj", () => {
6368
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
6469
generator.setStartupProject(0);
6570
let tasksJson = generator.createTasksConfiguration();
71+
isNotNull(tasksJson.tasks);
6672

6773
const watchTask = tasksJson.tasks.find(task => task.label === "watch");
74+
isNotNull(watchTask?.args);
6875
watchTask.args.should.not.contain("/property:GenerateFullPaths=true");
6976
});
7077

@@ -75,7 +82,8 @@ suite("Asset generation: csproj", () => {
7582
generator.setStartupProject(0);
7683
let tasksJson = generator.createTasksConfiguration();
7784

78-
const watchTask = tasksJson.tasks.find(task => task.label === "watch");
85+
const watchTask = tasksJson.tasks!.find(task => task.label === "watch");
86+
isNotNull(watchTask?.args);
7987
watchTask.args.should.not.contain("/consoleloggerparameters:NoSummary");
8088
});
8189

@@ -85,6 +93,8 @@ suite("Asset generation: csproj", () => {
8593
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
8694
generator.setStartupProject(0);
8795
let tasksJson = generator.createTasksConfiguration();
96+
isNotNull(tasksJson.tasks);
97+
isNotNull(tasksJson.tasks[0].args);
8898
let buildPath = tasksJson.tasks[0].args[1];
8999

90100
// ${workspaceFolder}/nested/project.json
@@ -100,7 +110,7 @@ suite("Asset generation: csproj", () => {
100110
let launchJson = parse(generator.createLaunchJsonConfigurations(ProgramLaunchType.Console), undefined, { disallowComments: true });
101111
let programPath: string = launchJson[0].program;
102112

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

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

117-
checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
127+
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
118128
});
119129
});
120130

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

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

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

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

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

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

185195
cwd.should.equal('${workspaceFolder}');
186196
hosted.should.equal(true);
@@ -197,7 +207,7 @@ suite("Asset generation: csproj", () => {
197207
const cwd = hostedBlazorLaunchConfig.cwd;
198208
const hosted = hostedBlazorLaunchConfig.hosted;
199209

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

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

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

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

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

228238
test("Add a new item to JSON", () => {
@@ -234,7 +244,7 @@ suite("Asset generation: csproj", () => {
234244
};
235245

236246
const newItem = { name: 'new-item' };
237-
const updated = updateJsonWithComments(JSON.stringify(original), [newItem], 'configurations', 'name', /*formattingOptions*/ null);
247+
const updated = updateJsonWithComments(JSON.stringify(original), [newItem], 'configurations', 'name', /*formattingOptions*/ null!);
238248
const parsed = jsonc.parse(updated);
239249
const configurations = parsed.configurations;
240250

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

255265
const updatedItem = { name: 'build', command: 'dotnet' };
256266

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

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

279289
const updatedItem = { name: 'build', command: 'dotnet' };
280290

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

284294
lines[0].trim().should.equal('// user comment in file');
@@ -336,12 +346,12 @@ function checkProgramPath(rootPath: string, programPath: string, targetPath: str
336346
function createMockWorkspaceFolder(rootPath: string): vscode.WorkspaceFolder {
337347
return {
338348
uri: vscode.Uri.file(rootPath),
339-
name: undefined,
340-
index: undefined
349+
name: '',
350+
index: -1
341351
};
342352
}
343353

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 {
354+
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 {
345355
return {
346356
MsBuild: {
347357
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from '.
1010
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1111
import * as path from 'path';
1212
import { assertWithPoll } from './poll';
13+
import { isNotNull } from '../testUtil';
1314

1415
const chai = require('chai');
1516
chai.use(require('chai-arrays'));
@@ -43,9 +44,11 @@ suite(`Code Action Rename ${testAssetWorkspace.description}`, function () {
4344
const codeActions = await vscode.commands.executeCommand<vscode.CodeAction[]>("vscode.executeCodeActionProvider", fileUri, new vscode.Range(0, 7, 0, 7));
4445
const codeAction = codeActions.find(codeAction => codeAction.title == "Rename file to C.cs");
4546
expect(codeAction, "Didn't find rename class code action");
47+
isNotNull(codeAction?.command?.command);
48+
isNotNull(codeAction?.command?.arguments);
4649

4750
await vscode.commands.executeCommand(codeAction.command.command, ...codeAction.command.arguments);
4851

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

test/integrationTests/codeLensProvider.integration.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as path from 'path';
99
import { should, expect } from 'chai';
1010
import { activateCSharpExtension, isSlnWithCsproj, isSlnWithGenerator } from './integrationHelpers';
1111
import testAssetWorkspace from './testAssets/testAssetWorkspace';
12+
import { isNotNull } from '../testUtil';
1213

1314
const chai = require('chai');
1415
chai.use(require('chai-arrays'));
@@ -60,7 +61,7 @@ suite(`CodeLensProvider: ${testAssetWorkspace.description}`, function () {
6061

6162
for (let codeLens of codeLenses) {
6263
expect(codeLens.isResolved).to.be.true;
63-
expect(codeLens.command).not.to.be.undefined;
64+
isNotNull(codeLens.command);
6465
expect(codeLens.command.title).to.equal("0 references");
6566
}
6667
});
@@ -104,7 +105,7 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()
104105

105106
for (let codeLens of codeLenses) {
106107
expect(codeLens.isResolved).to.be.true;
107-
expect(codeLens.command).not.to.be.undefined;
108+
isNotNull(codeLens.command);
108109
expect(codeLens.command.command).to.be.oneOf(['dotnet.test.run', 'dotnet.classTests.run', 'dotnet.test.debug', 'dotnet.classTests.debug']);
109110
expect(codeLens.command.title).to.be.oneOf(['Run Test', 'Run All Tests', 'Debug Test', 'Debug All Tests']);
110111
}
@@ -120,7 +121,7 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()
120121

121122
for (let codeLens of codeLenses) {
122123
expect(codeLens.isResolved).to.be.true;
123-
expect(codeLens.command).not.to.be.undefined;
124+
isNotNull(codeLens.command);
124125
expect(codeLens.command.command).to.be.equal('editor.action.showReferences');
125126
expect(codeLens.command.title).to.equal('0 references');
126127
}

test/integrationTests/diagnostics.integration.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { should, expect } from 'chai';
1010
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator, restartOmniSharpServer } from './integrationHelpers';
1111
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1212
import { poll, assertWithPoll, pollDoesNotHappen } from './poll';
13+
import { isNotNull } from '../testUtil';
1314

1415
const chai = require('chai');
1516
chai.use(require('chai-arrays'));
@@ -115,7 +116,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
115116
result => result.find(x => x.code === "CS0219") != undefined);
116117

117118
let cs0219 = result.find(x => x.code === "CS0219");
118-
expect(cs0219).to.not.be.undefined;
119+
isNotNull(cs0219);
119120
expect(cs0219.tags).to.include(vscode.DiagnosticTag.Unnecessary);
120121
});
121122

@@ -127,7 +128,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
127128
result => result.find(x => x.code === "CS8019") != undefined);
128129

129130
let cs8019 = result.find(x => x.code === "CS8019");
130-
expect(cs8019).to.not.be.undefined;
131+
isNotNull(cs8019);
131132
expect(cs8019.tags).to.include(vscode.DiagnosticTag.Unnecessary);
132133
});
133134

@@ -139,7 +140,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {
139140
result => result.find(x => x.code === "IDE0059") != undefined);
140141

141142
let ide0059 = result.find(x => x.code === "IDE0059");
142-
expect(ide0059).to.not.be.undefined;
143+
isNotNull(ide0059);
143144
expect(ide0059.tags).to.include(vscode.DiagnosticTag.Unnecessary);
144145
});
145146

0 commit comments

Comments
 (0)