Skip to content

Commit 719806f

Browse files
authored
Merge pull request #7541 from dibarbet/launch_integration_tests_profile
Use specific profile to debug/launch integration tests locally
2 parents e08ddaa + 33268c2 commit 719806f

File tree

6 files changed

+40
-42
lines changed

6 files changed

+40
-42
lines changed

.vscode/launch.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
"request": "launch",
1818
"runtimeExecutable": "${execPath}",
1919
"args": [
20-
// Create a temp profile that has no extensions / user settings.
21-
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
22-
"--profile-temp",
20+
// Launch VSCode using a specific profile to ensure that user settings are not used.
21+
// This profile must be imported into vscode before running this launch configuration.
22+
// The profile can be found under /test/csharp-standalone-profile.
23+
"--profile",
24+
"csharp-standalone-profile",
2325
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/lsp_tools_host_slnWithCsproj.code-workspace",
2426
"--extensionDevelopmentPath=${workspaceRoot}",
2527
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests"
@@ -40,9 +42,11 @@
4042
"request": "launch",
4143
"runtimeExecutable": "${execPath}",
4244
"args": [
43-
// Create a temp profile that has no extensions / user settings.
44-
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
45-
"--profile-temp",
45+
// Launch VSCode using a specific profile to ensure that user settings are not used.
46+
// This profile must be imported into vscode before running this launch configuration.
47+
// The profile can be found under /test/csharp-standalone-profile.
48+
"--profile",
49+
"csharp-standalone-profile",
4650
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
4751
"--extensionDevelopmentPath=${workspaceRoot}",
4852
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests"
@@ -63,9 +67,11 @@
6367
"request": "launch",
6468
"runtimeExecutable": "${execPath}",
6569
"args": [
66-
// Create a temp profile that has no extensions / user settings.
67-
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
68-
"--profile-temp",
70+
// Launch VSCode using a specific profile to ensure that user settings are not used.
71+
// This profile must be imported into vscode before running this launch configuration.
72+
// The profile can be found under /test/csharp-standalone-profile.
73+
"--profile",
74+
"csharp-standalone-profile",
6975
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_${input:omnisharpAssetName}.code-workspace",
7076
"--extensionDevelopmentPath=${workspaceRoot}",
7177
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
@@ -86,9 +92,11 @@
8692
"request": "launch",
8793
"runtimeExecutable": "${execPath}",
8894
"args": [
89-
// Create a temp profile that has no extensions / user settings.
90-
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
91-
"--profile-temp",
95+
// Launch VSCode using a specific profile to ensure that user settings are not used.
96+
// This profile must be imported into vscode before running this launch configuration.
97+
// The profile can be found under /test/csharp-standalone-profile.
98+
"--profile",
99+
"csharp-standalone-profile",
92100
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_lsp_${input:omnisharpAssetName}.code-workspace",
93101
"--extensionDevelopmentPath=${workspaceRoot}",
94102
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"

CONTRIBUTING.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ After completing the build steps:
5151

5252
#### Testing
5353

54-
To run tests:
54+
To run all tests, execute `npm run test`.
5555

56-
1. Execute `npm run test` or press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration selected.
57-
2. For integration tests, select either of the two 'current file' integration tests (one for roslyn and one for razor), from the drop-down and press <kbd>F5</kbd> to start debugging:
58-
- For Roslyn Server: `Launch Current File slnWithCsproj Integration Tests`
59-
- For Razor Server: `Launch Current File BasicRazorApp2_1 Integration Tests`
56+
To debug unit tests locally, press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration selected.
57+
58+
To debug integration tests
59+
1. Import the `csharp-standalone-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.
60+
2. Open any integration test file and <kbd>F5</kbd> launch with the correct launch configuration selected.
61+
- For integration tests inside `test/lsptoolshost`, use `Launch Current File slnWithCsproj Integration Tests`
62+
- For integration tests inside `test/razor`, use `Launch Current File BasicRazorApp2_1 Integration Tests`
63+
- For integration tests inside `test/omnisharp`, use one of the `Omnisharp:` current file profiles
6064

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

test/csharp-standalone-profile.code-profile

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

test/lsptoolshost/integrationTests/integrationHelpers.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ import { ServerState } from '../../../src/lsptoolshost/serverStateChange';
1111
import testAssetWorkspace from './testAssets/testAssetWorkspace';
1212

1313
export async function activateCSharpExtension(): Promise<void> {
14-
// Ensure the dependent extension exists - when launching via F5 launch.json we can't install the extension prior to opening vscode.
15-
const vscodeDotnetRuntimeExtensionId = 'ms-dotnettools.vscode-dotnet-runtime';
16-
const dotnetRuntimeExtension =
17-
vscode.extensions.getExtension<CSharpExtensionExports>(vscodeDotnetRuntimeExtensionId);
18-
if (!dotnetRuntimeExtension) {
19-
await vscode.commands.executeCommand('workbench.extensions.installExtension', vscodeDotnetRuntimeExtensionId, {
20-
donotSync: true,
21-
});
22-
await vscode.commands.executeCommand('workbench.action.reloadWindow');
23-
}
24-
2514
const csharpExtension = vscode.extensions.getExtension<CSharpExtensionExports>('ms-dotnettools.csharp');
2615
if (!csharpExtension) {
2716
throw new Error('Failed to find installation of ms-dotnettools.csharp');

test/omnisharp/omnisharpIntegrationTests/integrationHelpers.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ export interface ActivationResult {
1717
}
1818

1919
export async function activateCSharpExtension(): Promise<ActivationResult> {
20-
// Ensure the dependent extension exists - when launching via F5 launch.json we can't install the extension prior to opening vscode.
21-
const vscodeDotnetRuntimeExtensionId = 'ms-dotnettools.vscode-dotnet-runtime';
22-
const dotnetRuntimeExtension =
23-
vscode.extensions.getExtension<OmnisharpExtensionExports>(vscodeDotnetRuntimeExtensionId);
24-
if (!dotnetRuntimeExtension) {
25-
await vscode.commands.executeCommand('workbench.extensions.installExtension', vscodeDotnetRuntimeExtensionId);
26-
await vscode.commands.executeCommand('workbench.action.reloadWindow');
27-
}
28-
2920
const configuration = vscode.workspace.getConfiguration();
3021
configuration.update(
3122
'omnisharp.enableLspDriver',

test/vscodeLauncher.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,26 @@ function getSln(workspacePath: string): string | undefined {
1717

1818
async function main() {
1919
try {
20-
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.92.2');
20+
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
2121
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
2222

2323
console.log('Display: ' + process.env.DISPLAY);
2424

2525
const fullArgs = [...args, '--install-extension', 'ms-dotnettools.vscode-dotnet-runtime'];
26-
console.log(fullArgs);
27-
const result = cp.spawnSync(cli, fullArgs, {
26+
27+
// Since we're using shell execute, spaces in the CLI path will get interpeted as args
28+
// Therefore we wrap the CLI path in quotes as on MacOS the path can contain spaces.
29+
const cliWrapped = `"${cli}"`;
30+
console.log(`${cliWrapped} ${fullArgs}`);
31+
32+
const result = cp.spawnSync(cliWrapped, fullArgs, {
2833
encoding: 'utf-8',
2934
stdio: 'inherit',
3035
// Workaround as described in https://github.com/nodejs/node/issues/52554
3136
shell: true,
3237
});
33-
if (result.error) {
34-
throw new Error(`Failed to install the runtime extension: ${result.error}`);
38+
if (result.error || result.status !== 0) {
39+
throw new Error(`Failed to install the runtime extension: ${JSON.stringify(result)}`);
3540
}
3641

3742
// The folder containing the Extension Manifest package.json

0 commit comments

Comments
 (0)