MCPcopy
hub / github.com/dotnet/vscode-csharp / prepareVSCodeAndExecuteTests

Function prepareVSCodeAndExecuteTests

test/vscodeLauncher.ts:11–69  ·  view source on GitHub ↗
(
    extensionDevelopmentPath: string,
    extensionTestsPath: string,
    workspacePath: string,
    userDataDir: string,
    env: NodeJS.ProcessEnv
)

Source from the content-addressed store, hash-verified

9import { execChildProcess } from '../src/common';
10
11export async function prepareVSCodeAndExecuteTests(
12 extensionDevelopmentPath: string,
13 extensionTestsPath: string,
14 workspacePath: string,
15 userDataDir: string,
16 env: NodeJS.ProcessEnv
17): Promise<number> {
18 let vscodeVersion = 'insiders';
19 if (process.env.CODE_VERSION) {
20 console.log(`VSCode version overriden to ${process.env.CODE_VERSION}.`);
21 vscodeVersion = process.env.CODE_VERSION;
22 }
23
24 const vscodeExecutablePath = await downloadAndUnzipVSCode(vscodeVersion);
25 const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
26
27 console.log('Display: ' + env.DISPLAY);
28
29 // Different test runs may want to have Dev Kit be active or in-active.
30 // Rather than having to uninstall Dev Kit between different test runs, we use workspace settings
31 // to control which extensions are active - and we always install Dev Kit.
32 const extensionsToInstall = [
33 'ms-dotnettools.vscode-dotnet-runtime@3.0.0',
34 'ms-dotnettools.csharp',
35 'ms-dotnettools.csdevkit@1.92.5',
36 ];
37
38 await installExtensions(extensionsToInstall, cli, args);
39
40 // The folder containing the Extension Manifest package.json
41 // Passed to `--extensionDevelopmentPath`
42 env.CODE_EXTENSIONS_PATH = extensionDevelopmentPath;
43 env.RoslynWaiterEnabled = 'true';
44
45 console.log(`workspace path = '${workspacePath}'`);
46
47 const sln = getSln(workspacePath);
48 if (sln) {
49 // Run a build before the tests, to ensure that source generators are set up correctly
50 if (!process.env.DOTNET_ROOT) {
51 throw new Error('Environment variable DOTNET_ROOT is not set');
52 }
53
54 const dotnetPath = path.join(process.env.DOTNET_ROOT, 'dotnet');
55 await execChildProcess(`${dotnetPath} build ${sln}`, workspacePath, process.env);
56 }
57
58 // Download VS Code, unzip it and run the integration test
59 const exitCode = await runTests({
60 vscodeExecutablePath: vscodeExecutablePath,
61 extensionDevelopmentPath: extensionDevelopmentPath,
62 extensionTestsPath: extensionTestsPath,
63 // Launch with info logging as anything else is way too verbose and will hide test results.
64 launchArgs: [workspacePath, '-n', '--user-data-dir', userDataDir, '--log', 'ms-dotnettools.csharp:trace'],
65 extensionTestsEnv: env,
66 });
67
68 return exitCode;

Callers 1

runJestIntegrationTestFunction · 0.90

Calls 5

execChildProcessFunction · 0.90
installExtensionsFunction · 0.85
getSlnFunction · 0.85
runTestsFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected