Skip to content

Commit 791503c

Browse files
authored
Run all Razor tests with cohosting on (#8434)
2 parents 4d50c24 + b95cb46 commit 791503c

File tree

10 files changed

+105
-33
lines changed

10 files changed

+105
-33
lines changed

.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,33 @@
9292
"preLaunchTask": "packageDev",
9393
"internalConsoleOptions": "openOnSessionStart"
9494
},
95+
{
96+
"name": "[Razor Cohost] Run Current File Integration Test",
97+
"type": "extensionHost",
98+
"request": "launch",
99+
"runtimeExecutable": "${execPath}",
100+
"args": [
101+
// Launch VSCode using a specific profile to ensure that user settings are not used.
102+
// This profile must be imported into vscode before running this launch configuration.
103+
// The profile can be found under /test/csharp-test-profile.
104+
"--profile",
105+
"csharp-test-profile",
106+
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/RazorApp/.vscode/RazorApp.code-workspace",
107+
"--extensionDevelopmentPath=${workspaceRoot}",
108+
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests",
109+
"--log",
110+
"ms-dotnettools.csharp:trace"
111+
],
112+
"env": {
113+
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
114+
"TEST_FILE_FILTER": "${file}"
115+
},
116+
"sourceMaps": true,
117+
"outFiles": ["${workspaceRoot}/dist/*.js", "${workspaceRoot}/out/test/**/*.js"],
118+
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
119+
"preLaunchTask": "packageDev",
120+
"internalConsoleOptions": "openOnSessionStart"
121+
},
95122
{
96123
"name": "[O#] Run Current File Integration Tests",
97124
"type": "extensionHost",
@@ -197,6 +224,15 @@
197224
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
198225
"args": ["test:integration:razor"],
199226
"cwd": "${workspaceFolder}"
227+
},
228+
{
229+
"type": "node",
230+
"request": "launch",
231+
"name": "Razor Cohost integration tests",
232+
"preLaunchTask": "build",
233+
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
234+
"args": ["test:integration:razor:cohost"],
235+
"cwd": "${workspaceFolder}"
200236
}
201237
],
202238
"inputs": [

azure-pipelines/test-matrix.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
RazorTests:
2929
npmCommand: test:integration:razor
3030
isIntegration: true
31+
RazorCohostTests:
32+
npmCommand: test:integration:razor:cohost
33+
isIntegration: true
3134
pool: ${{ parameters.pool }}
3235
${{ if parameters.containerName }}:
3336
container: ${{ parameters.containerName }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"test:unit": "npm run compileDev && gulp test:unit",
7474
"test:integration:csharp": "npm run package && gulp test:integration:csharp",
7575
"test:integration:razor": "npm run package && gulp test:integration:razor",
76+
"test:integration:razor:cohost": "npm run package && gulp test:integration:razor:cohost",
7677
"test:integration:devkit": "npm run package && gulp test:integration:devkit",
7778
"profiling": "npm run package && gulp profiling",
7879
"test:artifacts": "npm run compileDev && gulp test:artifacts",

tasks/testTasks.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,27 @@ function createIntegrationTestSubTasks() {
8585
`Razor Test Integration ${projectName}`
8686
)
8787
);
88+
89+
gulp.task(`test:integration:razor:cohost:${projectName}`, async () =>
90+
// Register each test again, but as a regular test, which will run with cohosting on
91+
runIntegrationTest(
92+
projectName,
93+
path.join('razor', 'razorIntegrationTests'),
94+
`Razor Test Integration ${projectName}`
95+
)
96+
);
8897
}
8998

9099
gulp.task(
91100
'test:integration:razor',
92101
gulp.series(razorIntegrationTestProjects.map((projectName) => `test:integration:razor:${projectName}`))
93102
);
94103

104+
gulp.task(
105+
'test:integration:razor:cohost',
106+
gulp.series(razorIntegrationTestProjects.map((projectName) => `test:integration:razor:cohost:${projectName}`))
107+
);
108+
95109
gulp.task(
96110
'test:integration',
97111
gulp.series('test:integration:csharp', 'test:integration:devkit', 'test:integration:razor')

test/razor/razorIntegrationTests/completion.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach, describe } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

12-
integrationHelpers.describeIfDevKit(`Razor Hover ${testAssetWorkspace.description}`, function () {
12+
describe(`Razor Hover ${testAssetWorkspace.description}`, function () {
1313
beforeAll(async function () {
1414
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
1515
return;

test/razor/razorIntegrationTests/formatting.integration.test.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach, describe } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

12-
integrationHelpers.describeIfDevKit(`Razor Formatting ${testAssetWorkspace.description}`, function () {
12+
describe(`Razor Formatting ${testAssetWorkspace.description}`, function () {
1313
beforeAll(async function () {
1414
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
1515
return;
@@ -41,30 +41,42 @@ integrationHelpers.describeIfDevKit(`Razor Formatting ${testAssetWorkspace.descr
4141
throw new Error('No active document');
4242
}
4343

44-
const edits = <vscode.TextEdit[]>await vscode.commands.executeCommand(
45-
'vscode.executeFormatDocumentProvider',
46-
activeDocument,
47-
{
48-
insertSpaces: true,
49-
tabSize: 4,
50-
}
51-
);
44+
const duration = 30 * 1000;
45+
const step = 500;
46+
47+
await integrationHelpers.waitForExpectedResult(
48+
async () => {
49+
const edits = <vscode.TextEdit[]>await vscode.commands.executeCommand(
50+
'vscode.executeFormatDocumentProvider',
51+
activeDocument,
52+
{
53+
insertSpaces: true,
54+
tabSize: 4,
55+
}
56+
);
5257

53-
expect(edits).toHaveLength(13);
58+
return edits;
59+
},
60+
duration,
61+
step,
62+
(edits) => {
63+
expect(edits).toHaveLength(13);
5464

55-
assertEditEqual(edits[0], 3, 0, 3, 0, ' ');
56-
assertEditEqual(edits[1], 3, 7, 3, 17, '');
57-
assertEditEqual(edits[2], 3, 18, 3, 31, '');
58-
assertEditEqual(edits[3], 3, 37, 3, 38, '');
59-
assertEditEqual(edits[4], 3, 39, 3, 57, '');
60-
assertEditEqual(edits[5], 3, 59, 3, 69, '');
61-
assertEditEqual(edits[6], 3, 70, 3, 86, '');
62-
assertEditEqual(edits[7], 3, 87, 3, 99, '');
63-
assertEditEqual(edits[8], 3, 100, 3, 108, '');
64-
assertEditEqual(edits[9], 5, 0, 5, 0, ' ');
65-
assertEditEqual(edits[10], 6, 0, 6, 0, ' ');
66-
assertEditEqual(edits[11], 7, 0, 7, 0, ' ');
67-
assertEditEqual(edits[12], 8, 0, 8, 0, ' ');
65+
assertEditEqual(edits[0], 3, 0, 3, 0, ' ');
66+
assertEditEqual(edits[1], 3, 7, 3, 17, '');
67+
assertEditEqual(edits[2], 3, 18, 3, 31, '');
68+
assertEditEqual(edits[3], 3, 37, 3, 38, '');
69+
assertEditEqual(edits[4], 3, 39, 3, 57, '');
70+
assertEditEqual(edits[5], 3, 59, 3, 69, '');
71+
assertEditEqual(edits[6], 3, 70, 3, 86, '');
72+
assertEditEqual(edits[7], 3, 87, 3, 99, '');
73+
assertEditEqual(edits[8], 3, 100, 3, 108, '');
74+
assertEditEqual(edits[9], 5, 0, 5, 0, ' ');
75+
assertEditEqual(edits[10], 6, 0, 6, 0, ' ');
76+
assertEditEqual(edits[11], 7, 0, 7, 0, ' ');
77+
assertEditEqual(edits[12], 8, 0, 8, 0, ' ');
78+
}
79+
);
6880

6981
function assertEditEqual(
7082
actual: vscode.TextEdit,

test/razor/razorIntegrationTests/hover.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach, describe } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

12-
integrationHelpers.describeIfDevKit(`Razor Hover ${testAssetWorkspace.description}`, function () {
12+
describe(`Razor Hover ${testAssetWorkspace.description}`, function () {
1313
beforeAll(async function () {
1414
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
1515
return;

test/razor/razorIntegrationTests/reference.integration.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach, describe } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

12-
integrationHelpers.describeIfDevKit(`Razor References ${testAssetWorkspace.description}`, function () {
12+
describe(`Razor References ${testAssetWorkspace.description}`, function () {
1313
beforeAll(async function () {
1414
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
1515
return;
@@ -127,6 +127,11 @@ integrationHelpers.describeIfDevKit(`Razor References ${testAssetWorkspace.descr
127127
});
128128

129129
test('Find All References - CSharp', async () => {
130+
if (!integrationHelpers.usingDevKit()) {
131+
// If we're not using devkit, then it means we are testing cohosting, and FAR from C# doesn't currently work in cohosting.
132+
return;
133+
}
134+
130135
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
131136
return;
132137
}

test/razor/razorIntegrationTests/rename.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach, describe } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

12-
integrationHelpers.describeIfDevKit(`Razor Rename ${testAssetWorkspace.description}`, function () {
12+
describe(`Razor Rename ${testAssetWorkspace.description}`, function () {
1313
beforeAll(async function () {
1414
if (!integrationHelpers.isRazorWorkspace(vscode.workspace)) {
1515
return;

test/razor/razorIntegrationTests/testAssets/RazorApp/.vscode/RazorApp.code-workspace

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"dotnet.server.useOmnisharp": false,
1010
"omnisharp.enableLspDriver": false,
1111
"razor.server.trace": "Trace",
12-
"dotnet.preferCSharpExtension": true
12+
"dotnet.preferCSharpExtension": true,
13+
"razor.languageServer.cohostingEnabled": true
1314
}
1415
}

0 commit comments

Comments
 (0)