Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine test compile step into normal compile #5666

Merged
merged 2 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
44 changes: 27 additions & 17 deletions test/featureTests/assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as jsonc from 'jsonc-parser';
import { AssetGenerator, ProgramLaunchType, replaceCommentPropertiesWithComments, updateJsonWithComments } from '../../src/assets';
import { parse } from 'jsonc-parser';
import { use as chaiUse, should } from 'chai';
import { isNotNull } from '../testUtil';

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

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

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

// We do not check the watch task since this parameter can break hot reload scenarios.
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 @@ -50,11 +54,12 @@ suite("Asset generation: csproj", () => {
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
generator.setStartupProject(0);
let tasksJson = generator.createTasksConfiguration();
isNotNull(tasksJson.tasks);

// We do not check the watch task since this parameter can break hot reload scenarios.
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 @@ -63,8 +68,10 @@ suite("Asset generation: csproj", () => {
let generator = new AssetGenerator(info, createMockWorkspaceFolder(rootPath));
generator.setStartupProject(0);
let tasksJson = generator.createTasksConfiguration();
isNotNull(tasksJson.tasks);

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

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

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

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

// ${workspaceFolder}/nested/project.json
Expand All @@ -100,7 +110,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 +124,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 +136,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 +152,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 +190,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 +207,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 +221,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 +232,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 +244,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 +264,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 +288,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 +346,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
5 changes: 4 additions & 1 deletion test/integrationTests/codeActionRename.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from '.
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import * as path from 'path';
import { assertWithPoll } from './poll';
import { isNotNull } from '../testUtil';

const chai = require('chai');
chai.use(require('chai-arrays'));
Expand Down Expand Up @@ -43,9 +44,11 @@ suite(`Code Action Rename ${testAssetWorkspace.description}`, function () {
const codeActions = await vscode.commands.executeCommand<vscode.CodeAction[]>("vscode.executeCodeActionProvider", fileUri, new vscode.Range(0, 7, 0, 7));
const codeAction = codeActions.find(codeAction => codeAction.title == "Rename file to C.cs");
expect(codeAction, "Didn't find rename class code action");
isNotNull(codeAction?.command?.command);
isNotNull(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"));
});
});
7 changes: 4 additions & 3 deletions test/integrationTests/codeLensProvider.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as path from 'path';
import { should, expect } from 'chai';
import { activateCSharpExtension, isSlnWithCsproj, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { isNotNull } from '../testUtil';

const chai = require('chai');
chai.use(require('chai-arrays'));
Expand Down Expand Up @@ -60,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;
isNotNull(codeLens.command);
expect(codeLens.command.title).to.equal("0 references");
}
});
Expand Down Expand Up @@ -104,7 +105,7 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()

for (let codeLens of codeLenses) {
expect(codeLens.isResolved).to.be.true;
expect(codeLens.command).not.to.be.undefined;
isNotNull(codeLens.command);
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 @@ -120,7 +121,7 @@ suite(`CodeLensProvider options: ${testAssetWorkspace.description}`, function ()

for (let codeLens of codeLenses) {
expect(codeLens.isResolved).to.be.true;
expect(codeLens.command).not.to.be.undefined;
isNotNull(codeLens.command);
expect(codeLens.command.command).to.be.equal('editor.action.showReferences');
expect(codeLens.command.title).to.equal('0 references');
}
Expand Down
7 changes: 4 additions & 3 deletions test/integrationTests/diagnostics.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { should, expect } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator, restartOmniSharpServer } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { poll, assertWithPoll, pollDoesNotHappen } from './poll';
import { isNotNull } from '../testUtil';

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

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

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

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

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

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

Expand Down
Loading