Skip to content

Commit

Permalink
Combine test compile step into normal compile
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed May 3, 2023
1 parent fecf024 commit ed2899a
Show file tree
Hide file tree
Showing 38 changed files with 185 additions and 192 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
"compileDev": "tsc -p ./ && tslint -p ./ && webpack --mode development",
"watch": "tsc -watch -p ./",
"tdd": "mocha --config ./.mocharc.jsonc --watch --watch-extensions ts test/unitTests/**/*.test.ts*",
"test": "tsc -p test && gulp test",
"test:unit": "tsc -p test && gulp test:unit",
"test:feature": "tsc -p test && gulp test:feature",
"test:integration": "tsc -p test && gulp test:integration",
"test:integration:singleCsproj": "tsc -p test && gulp test:integration:singleCsproj",
"test:integration:slnWithCsproj": "tsc -p test && gulp test:integration:slnWithCsproj",
"test:integration:slnFilterWithCsproj": "tsc -p test && gulp test:integration:slnFilterWithCsproj",
"test:release": "tsc -p test && mocha out/test/releaseTests/**/*.test.js",
"test:artifacts": "tsc -p test && mocha out/test/artifactTests/**/*.test.js",
"test": "tsc -p ./ && gulp test",
"test:unit": "tsc -p ./ && gulp test:unit",
"test:feature": "tsc -p ./ && gulp test:feature",
"test:integration": "tsc -p ./ && gulp test:integration",
"test:integration:singleCsproj": "tsc -p ./ && gulp test:integration:singleCsproj",
"test:integration:slnWithCsproj": "tsc -p ./ && gulp test:integration:slnWithCsproj",
"test:integration:slnFilterWithCsproj": "tsc -p ./ && gulp test:integration:slnFilterWithCsproj",
"test:release": "tsc -p ./ && mocha out/test/releaseTests/**/*.test.js",
"test:artifacts": "tsc -p ./ && mocha out/test/artifactTests/**/*.test.js",
"unpackage:vsix": "gulp vsix:release:unpackage",
"updatePackageDependencies": "gulp updatePackageDependencies"
},
Expand Down
48 changes: 24 additions & 24 deletions test/featureTests/assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ suite("Asset generation: csproj", () => {
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
generator.setStartupProject(0);
let tasksJson = generator.createTasksConfiguration();
let buildPath = tasksJson.tasks[0].args[1];
let buildPath = tasksJson.tasks![0].args![1];

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

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

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

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

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

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

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

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

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

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});
});

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});

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

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

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

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

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});

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

checkProgramPath(rootPath, programPath, info.MsBuild.Projects[0].TargetPath);
checkProgramPath(rootPath, programPath, info.MsBuild!.Projects[0].TargetPath);
});

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

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

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

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

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

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

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

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

lines[0].trim().should.equal('// user comment in file');
Expand Down Expand Up @@ -336,12 +336,12 @@ function checkProgramPath(rootPath: string, programPath: string, targetPath: str
function createMockWorkspaceFolder(rootPath: string): vscode.WorkspaceFolder {
return {
uri: vscode.Uri.file(rootPath),
name: undefined,
index: undefined
name: '',
index: -1
};
}

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 {
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 {
return {
MsBuild: {
SolutionPath: '',
Expand Down
6 changes: 3 additions & 3 deletions test/featureTests/processPicker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ suite("Remote Process Picker: Validate quoting arguments.", () => {
process1.name.should.equal('System Idle Process');
process1.pid.should.equal('0');

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

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

process4.commandLine.should.equal('C:\\WINDOWS\\system32\\conhost.exe 0x4');
process4.commandLine!.should.equal('C:\\WINDOWS\\system32\\conhost.exe 0x4');
process4.name.should.equal('conhost.exe');
process4.pid.should.equal('33732');
});
Expand Down
6 changes: 1 addition & 5 deletions test/integrationTests/advisor.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ suite(`Advisor ${testAssetWorkspace.description}`, function () {
const activation = await activateCSharpExtension();
await testAssetWorkspace.restore();

if (!activation) {
throw new Error('Cannot activate extension.');
} else {
advisor = activation.advisor;
}
advisor = activation.advisor;

let fileName = 'completion.cs';
let dir = testAssetWorkspace.projects[0].projectDirectoryPath;
Expand Down
4 changes: 2 additions & 2 deletions test/integrationTests/codeActionRename.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ suite(`Code Action Rename ${testAssetWorkspace.description}`, function () {
const codeAction = codeActions.find(codeAction => codeAction.title == "Rename file to C.cs");
expect(codeAction, "Didn't find rename class code action");

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

await assertWithPoll(() => { }, 15 * 1000, 500, _ => expect(vscode.window.activeTextEditor.document.fileName).contains("C.cs"));
await assertWithPoll(() => { }, 15 * 1000, 500, _ => expect(vscode.window.activeTextEditor!.document.fileName).contains("C.cs"));
});
});
10 changes: 5 additions & 5 deletions test/integrationTests/codeLensProvider.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ suite(`CodeLensProvider: ${testAssetWorkspace.description}`, function () {
for (let codeLens of codeLenses) {
expect(codeLens.isResolved).to.be.true;
expect(codeLens.command).not.to.be.undefined;
expect(codeLens.command.title).to.equal("0 references");
expect(codeLens.command!.title).to.equal("0 references");
}
});
});
Expand Down Expand Up @@ -105,8 +105,8 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()
for (let codeLens of codeLenses) {
expect(codeLens.isResolved).to.be.true;
expect(codeLens.command).not.to.be.undefined;
expect(codeLens.command.command).to.be.oneOf(['dotnet.test.run', 'dotnet.classTests.run', 'dotnet.test.debug', 'dotnet.classTests.debug']);
expect(codeLens.command.title).to.be.oneOf(['Run Test', 'Run All Tests', 'Debug Test', 'Debug All Tests']);
expect(codeLens.command!.command).to.be.oneOf(['dotnet.test.run', 'dotnet.classTests.run', 'dotnet.test.debug', 'dotnet.classTests.debug']);
expect(codeLens.command!.title).to.be.oneOf(['Run Test', 'Run All Tests', 'Debug Test', 'Debug All Tests']);
}
});

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

Expand Down
6 changes: 3 additions & 3 deletions test/integrationTests/diagnostics.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ suite(`DiagnosticProvider: ${testAssetWorkspace.description}`, function () {

let cs0219 = result.find(x => x.code === "CS0219");
expect(cs0219).to.not.be.undefined;
expect(cs0219.tags).to.include(vscode.DiagnosticTag.Unnecessary);
expect(cs0219!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
});

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

let cs8019 = result.find(x => x.code === "CS8019");
expect(cs8019).to.not.be.undefined;
expect(cs8019.tags).to.include(vscode.DiagnosticTag.Unnecessary);
expect(cs8019!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
});

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

let ide0059 = result.find(x => x.code === "IDE0059");
expect(ide0059).to.not.be.undefined;
expect(ide0059.tags).to.include(vscode.DiagnosticTag.Unnecessary);
expect(ide0059!.tags).to.include(vscode.DiagnosticTag.Unnecessary);
});

test("On small workspaces also show/fetch closed document analysis results", async function () {
Expand Down
10 changes: 5 additions & 5 deletions test/integrationTests/dotnetTest.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ suite(`DotnetTest: ${testAssetWorkspace.description}`, function () {
await vscode.commands.executeCommand('dotnet.test.runTestsInContext');

const event = await eventWaiter;
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;

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

const event = await eventWaiter;
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;

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

const event = await eventWaiter;
const runTestsRequest = <V2.RunTestsInContextRequest>event.request.data;
const runTestsRequest = <V2.RunTestsInContextRequest>event!.request.data;

expect(runTestsRequest.RunSettings).to.be.not.null;
expect(runTestsRequest.RunSettings.endsWith(endingPath), "Path includes relative path").to.be.true;
expect(path.isAbsolute(runTestsRequest.RunSettings), "Path is absolute").to.be.true;
expect(runTestsRequest.RunSettings!.endsWith(endingPath), "Path includes relative path").to.be.true;
expect(path.isAbsolute(runTestsRequest.RunSettings!), "Path is absolute").to.be.true;
});
});

4 changes: 2 additions & 2 deletions test/integrationTests/inlayHints.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ suite(`Inlay Hints ${testAssetWorkspace.description}`, function () {
return;
}

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

assertTextEditEqual(actualTextEdit, expectedTextEdit);
}
Expand Down
Loading

0 comments on commit ed2899a

Please sign in to comment.