Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/onboardDebug/test/node/parseLaunchConfigFromResponse.spec.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { expect, suite, test } from 'vitest';
7
import { parseLaunchConfigFromResponse } from '../../node/parseLaunchConfigFromResponse';
8
9
const input = `\`\`\`json
10
{
11
"configurations": [
12
{
13
"type": "lldb",
14
"request": "launch",
15
"name": "Cargo Run",
16
"program": "\${workspaceFolder}/target/debug/\${workspaceFolderBasename}",
17
"preLaunchTask": "cargo build"
18
}
19
],
20
"inputs": [
21
{
22
"type": "promptString",
23
"id": "executableName",
24
"description": "Name of your executable"
25
}
26
]
27
}
28
\`\`\`
29
It looks like you build your project using Cargo, so let's add a \`tasks.json\` to do that before each debug session:
30
\`\`\`json
31
{
32
"tasks": [
33
{
34
"type": "shell",
35
"label": "cargo build",
36
"command": "cargo",
37
"args": [
38
"build"
39
]
40
}
41
]
42
}
43
\`\`\`
44
`;
45
46
suite('parseLaunchConfigFromResponse', () => {
47
test('works', () => {
48
expect(parseLaunchConfigFromResponse(input, {
49
allAcrossExtensionHosts: [],
50
} as any)).toMatchInlineSnapshot(`
51
{
52
"configurations": [
53
{
54
"name": "Cargo Run",
55
"preLaunchTask": "cargo build",
56
"program": "\${workspaceFolder}/target/debug/\${workspaceFolderBasename}",
57
"request": "launch",
58
"type": "lldb",
59
},
60
],
61
"inputs": [
62
{
63
"description": "Name of your executable",
64
"id": "executableName",
65
"type": "promptString",
66
},
67
],
68
"tasks": [
69
{
70
"args": [
71
"build",
72
],
73
"command": "cargo",
74
"label": "cargo build",
75
"type": "shell",
76
},
77
],
78
}
79
`);
80
});
81
});
82
83