Skip to content

Commit 850affd

Browse files
author
Andrew Hall
authored
Add razor rename integration tests (#7675)
Adds a new rename test and updates the test project to be more modern and target net6. Makes razor integration tests run on windows only until issues with linux/mac are identified and fixed
1 parent 275acc1 commit 850affd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+701
-125
lines changed

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"internalConsoleOptions": "openOnSessionStart"
6767
},
6868
{
69-
"name": "Launch Current File BasicRazorApp2_1 Integration Tests",
69+
"name": "[Razor] Run Current File Integration Test",
7070
"type": "extensionHost",
7171
"request": "launch",
7272
"runtimeExecutable": "${execPath}",
@@ -76,7 +76,7 @@
7676
// The profile can be found under /test/csharp-test-profile.
7777
"--profile",
7878
"csharp-test-profile",
79-
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
79+
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/RazorApp/.vscode/RazorApp.code-workspace",
8080
"--extensionDevelopmentPath=${workspaceRoot}",
8181
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests",
8282
"--log",
@@ -89,7 +89,7 @@
8989
"sourceMaps": true,
9090
"outFiles": ["${workspaceRoot}/dist/*.js", "${workspaceRoot}/out/test/**/*.js"],
9191
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
92-
"preLaunchTask": "buildDev",
92+
"preLaunchTask": "buildTest",
9393
"internalConsoleOptions": "openOnSessionStart"
9494
},
9595
{
@@ -204,7 +204,7 @@
204204
"id": "omnisharpAssetName",
205205
"description": "The name of the asset folder to use for the OmniSharp integration test.",
206206
"type": "pickString",
207-
"options": ["singleCsproj", "BasicRazorApp2_1", "slnWithCsproj", "slnFilterWithCsproj", "slnWithGenerator"]
207+
"options": ["singleCsproj", "RazorApp", "slnWithCsproj", "slnFilterWithCsproj", "slnWithGenerator"]
208208
},
209209
{
210210
"id": "gulpTaskName",

.vscode/tasks.json

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
{
2-
"version": "2.0.0",
3-
"presentation": {
4-
"echo": true,
5-
"reveal": "always",
6-
"focus": false,
7-
"panel": "shared"
8-
},
9-
"tasks": [
10-
{
11-
"label": "build",
12-
"command": "npm",
13-
"type": "shell",
14-
"args": [
15-
"run",
16-
"compile"
17-
],
18-
"group": {
19-
"kind": "build",
20-
"isDefault": true
21-
}
22-
},
23-
{
24-
"label": "buildDev",
25-
"command": "npm",
26-
"type": "shell",
27-
"args": [
28-
"run",
29-
"compileDev"
30-
],
31-
"group": {
32-
"kind": "build",
33-
"isDefault": true
34-
}
35-
},
36-
{
37-
"label": "test",
38-
"command": "echo",
39-
"group": {
40-
"kind": "test",
41-
"isDefault": true
42-
},
43-
"args": [
44-
"Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration."
45-
]
46-
},
47-
]
48-
}
2+
"version": "2.0.0",
3+
"presentation": {
4+
"echo": true,
5+
"reveal": "always",
6+
"focus": false,
7+
"panel": "shared"
8+
},
9+
"tasks": [
10+
{
11+
"label": "build",
12+
"command": "npm",
13+
"type": "shell",
14+
"args": ["run", "compile"],
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"label": "buildDev",
22+
"command": "npm",
23+
"type": "shell",
24+
"args": ["run", "compileDev"],
25+
"group": {
26+
"kind": "build",
27+
"isDefault": true
28+
}
29+
},
30+
{
31+
"label": "buildTest",
32+
"command": "npm",
33+
"type": "shell",
34+
"args": ["run", "compileTest"],
35+
"group": {
36+
"kind": "build",
37+
"isDefault": true
38+
}
39+
},
40+
{
41+
"label": "test",
42+
"command": "echo",
43+
"group": {
44+
"kind": "test",
45+
"isDefault": true
46+
},
47+
"args": ["Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration."]
48+
}
49+
]
50+
}

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To debug integration tests
5959
1. Import the `csharp-test-profile.code-profile` in VSCode to setup a clean profile in which to run integration tests. This must be imported at least once to use the launch configurations (ensure the extensions are updated in the profile).
6060
2. Open any integration test file and <kbd>F5</kbd> launch with the correct launch configuration selected.
6161
- For integration tests inside `test/lsptoolshost`, use either `Launch Current File slnWithCsproj Integration Tests` or `[DevKit] Launch Current File slnWithCsproj Integration Tests` (to run tests using C# + C# Dev Kit)
62-
- For integration tests inside `test/razor`, use `Launch Current File BasicRazorApp2_1 Integration Tests`
62+
- For integration tests inside `test/razor`, use `[Razor] Run Current File Integration Test`
6363
- For integration tests inside `test/omnisharp`, use one of the `Omnisharp:` current file profiles
6464

6565
These will allow you to actually debug the test, but the 'Razor integration tests' configuration does not.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"compile": "tsc -p ./ && npx eslint ./ && npm run l10nDevGenerateLocalizationBundle && npm run compile:razorTextMate",
6666
"compile:razorTextMate": "npx js-yaml src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml > src/razor/syntaxes/aspnetcorerazor.tmLanguage.json",
6767
"compileDev": "tsc -p ./ && npx eslint ./ && webpack --mode development && npm run l10nDevGenerateLocalizationBundle",
68+
"compileTest": "tsc -p ./ && webpack --mode development",
6869
"watch": "tsc -watch -p ./",
6970
"test": "tsc -p ./ && gulp test",
7071
"test:withoutDevKit": "tsc -p ./ && gulp test:withoutDevKit",

tasks/testTasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function createIntegrationTestSubTasks() {
7575
gulp.series(integrationTestProjects.map((projectName) => `test:integration:devkit:${projectName}`))
7676
);
7777

78-
const razorIntegrationTestProjects = ['BasicRazorApp2_1'];
78+
const razorIntegrationTestProjects = ['RazorApp'];
7979
for (const projectName of razorIntegrationTestProjects) {
8080
gulp.task(`test:razorintegration:${projectName}`, async () =>
8181
runIntegrationTest(

test/lsptoolshost/integrationTests/integrationHelpers.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CSharpExtensionExports } from '../../../src/csharpExtensionExports';
1010
import { existsSync } from 'fs';
1111
import { ServerState } from '../../../src/lsptoolshost/serverStateChange';
1212
import testAssetWorkspace from './testAssets/testAssetWorkspace';
13-
import { EOL } from 'os';
13+
import { EOL, platform } from 'os';
1414
import { describe, expect, test } from '@jest/globals';
1515

1616
export async function activateCSharpExtension(): Promise<void> {
@@ -102,7 +102,7 @@ export async function restartLanguageServer(): Promise<void> {
102102
}
103103

104104
export function isRazorWorkspace(workspace: typeof vscode.workspace) {
105-
return isGivenSln(workspace, 'BasicRazorApp2_1');
105+
return isGivenSln(workspace, 'RazorApp');
106106
}
107107

108108
export function isSlnWithGenerator(workspace: typeof vscode.workspace) {
@@ -229,8 +229,12 @@ export async function expectText(document: vscode.TextDocument, expectedLines: s
229229

230230
export const describeIfCSharp = describeIf(!usingDevKit());
231231
export const describeIfDevKit = describeIf(usingDevKit());
232+
export const describeIfNotMacOS = describeIf(!isMacOS());
233+
export const describeIfWindows = describeIf(isWindows());
232234
export const testIfCSharp = testIf(!usingDevKit());
233235
export const testIfDevKit = testIf(usingDevKit());
236+
export const testIfNotMacOS = testIf(!isMacOS());
237+
export const testIfWindows = testIf(isWindows());
234238

235239
function describeIf(condition: boolean) {
236240
return condition ? describe : describe.skip;
@@ -239,3 +243,13 @@ function describeIf(condition: boolean) {
239243
function testIf(condition: boolean) {
240244
return condition ? test : test.skip;
241245
}
246+
247+
function isMacOS() {
248+
const currentPlatform = platform();
249+
return currentPlatform === 'darwin';
250+
}
251+
252+
function isWindows() {
253+
const currentPlatform = platform();
254+
return currentPlatform === 'win32';
255+
}

test/lsptoolshost/integrationTests/testAssets/basicRazorApp21.ts renamed to test/lsptoolshost/integrationTests/testAssets/razorApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import { ITestAssetWorkspace } from './testAssets';
77

88
const workspace: ITestAssetWorkspace = {
9-
description: 'Basic Razor app',
9+
description: 'Razor App',
1010
projects: [
1111
{
12-
relativeFilePath: 'BasicRazorApp2_1.csproj',
12+
relativeFilePath: 'RazorApp.csproj',
1313
},
1414
],
1515
};

test/lsptoolshost/integrationTests/testAssets/testAssetWorkspace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { ITestAssetWorkspace, TestAssetWorkspace } from './testAssets';
1111
import singleCsproj from './singleCsproj';
1212
import slnWithCsproj from './slnWithCsproj';
1313
import slnFilterWithCsproj from './slnFilterWithCsproj';
14-
import BasicRazorApp2_1 from './basicRazorApp21';
14+
import RazorApp from './razorApp';
1515
import slnWithGenerator from './slnWithGenerator';
1616

1717
const testAssetWorkspaces: { [x: string]: ITestAssetWorkspace } = {
1818
singleCsproj,
1919
slnWithCsproj,
2020
slnFilterWithCsproj,
21-
BasicRazorApp2_1,
21+
RazorApp,
2222
slnWithGenerator,
2323
};
2424

test/omnisharp/omnisharpIntegrationTests/testAssets/activeTestAssetWorkspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ITestAssetWorkspace } from '../../../lsptoolshost/integrationTests/test
1111
import singleCsproj from '../../../lsptoolshost/integrationTests/testAssets/singleCsproj';
1212
import slnWithCsproj from '../../../lsptoolshost/integrationTests/testAssets/slnWithCsproj';
1313
import slnFilterWithCsproj from '../../../lsptoolshost/integrationTests/testAssets/slnFilterWithCsproj';
14-
import BasicRazorApp2_1 from '../../../lsptoolshost/integrationTests/testAssets/basicRazorApp21';
14+
import BasicRazorApp2_1 from '../../../lsptoolshost/integrationTests/testAssets/razorApp';
1515
import slnWithGenerator from '../../../lsptoolshost/integrationTests/testAssets/slnWithGenerator';
1616
import { OmnisharpTestAssetWorkspace } from './omnisharpTestAssetWorkspace';
1717

test/razor/razorIntegrationTests/formatting.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 { describe, beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
8+
import { beforeAll, afterAll, test, expect, beforeEach } from '@jest/globals';
99
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1010
import * as integrationHelpers from '../../lsptoolshost/integrationTests/integrationHelpers';
1111

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

0 commit comments

Comments
 (0)