Skip to content

Commit d600e69

Browse files
Merge user launch configurations and tasks from per-solution .vscode.d folder into workspace files (#80)
Co-authored-by: Evgueni Driouk <edriouk@arm.com>
1 parent d16e705 commit d600e69

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

src/debug/debug-launch-provider.test.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@ describe('DebugLaunchProvider', () => {
9898
const workspaceFolderUri = Uri.file(tmpDir);
9999
const workspaceFolder = workspaceFolderUri.fsPath; // platform-specific string path
100100
const tasksJsonFile = path.join(workspaceFolder, '.vscode', 'tasks.json');
101-
const tasksJsonDir = path.join(workspaceFolder, '.vscode', 'tasks.json.d');
102101
const launchJsonFile = path.join(workspaceFolder, '.vscode', 'launch.json');
103-
const launchJsonDir = path.join(workspaceFolder, '.vscode', 'launch.json.d');
104102
const solutionFolder = path.join(workspaceFolder, 'solution');
105-
const solutionTasksJsonDir = path.join(solutionFolder, '.vscode', 'tasks.json.d');
106-
const solutionLaunchJsonDir = path.join(solutionFolder, '.vscode', 'launch.json.d');
103+
const solutionVscodeDir = path.join(solutionFolder, '.vscode.d');
107104

108105
afterAll(async () => {
109106
testDataHandler.dispose();
@@ -112,10 +109,7 @@ describe('DebugLaunchProvider', () => {
112109
afterEach(() => {
113110
testDataHandler.rmFile(tasksJsonFile);
114111
testDataHandler.rmFile(launchJsonFile);
115-
testDataHandler.rmDir(tasksJsonDir);
116-
testDataHandler.rmDir(launchJsonDir);
117-
testDataHandler.rmDir(solutionTasksJsonDir);
118-
testDataHandler.rmDir(solutionLaunchJsonDir);
112+
testDataHandler.rmDir(solutionVscodeDir);
119113
});
120114

121115
describe('loadCbuildRunYml', () => {
@@ -221,7 +215,7 @@ describe('DebugLaunchProvider', () => {
221215
expect(expectedContent).toEqual(mockChangedContent);
222216
});
223217

224-
it('should include all files from tasks.json.d', async () => {
218+
it('should include all tasks from .vscode.d/tasks.json', async () => {
225219
const debugLaunchProvider = new DebugLaunchProviderTest();
226220
debugLaunchProvider.solutionManagerMock.getCsolution.mockReturnValue(csolutionFactory({ solutionDir: solutionFolder }));
227221

@@ -232,19 +226,16 @@ describe('DebugLaunchProvider', () => {
232226
{ id: 'input1', type: 'string', description: 'Input 1' },
233227
];
234228
const extraTasks = [
235-
{ label: 'Custom Task', type: 'shell', command: '' },
236-
];
237-
const solutionTasks = [
238-
{ label: 'Solution Task', type: 'shell', command: '' },
229+
{ label: 'Custom Task 1', type: 'shell', command: 'echo "Task 1"' },
230+
{ label: 'Custom Task 2', type: 'shell', command: 'echo "Task 2"' },
239231
];
240232

241-
fsUtils.writeTextFile(path.join(tasksJsonDir, 'extra.json'), JSON.stringify({ version: '2.0.0', tasks: extraTasks, inputs: extraInputs }, null, 4));
242-
fsUtils.writeTextFile(path.join(solutionTasksJsonDir, 'solution.json'), JSON.stringify({ version: '2.0.0', tasks: solutionTasks }, null, 4));
233+
fsUtils.writeTextFile(path.join(solutionVscodeDir, 'tasks.json'), JSON.stringify({ version: '2.0.0', tasks: extraTasks, inputs: extraInputs }, null, 4));
243234

244235
const mockContent = JSON.stringify({ version: '2.0.0', tasks }, null, 4);
245236
fsUtils.writeTextFile(tasksJsonFile, mockContent);
246237

247-
const mockChangedContent = JSON.stringify({ version: '2.0.0', inputs: [...extraInputs], tasks: [...tasks, ...extraTasks, ...solutionTasks] }, null, 4);
238+
const mockChangedContent = JSON.stringify({ version: '2.0.0', inputs: [...extraInputs], tasks: [...tasks, ...extraTasks ] }, null, 4);
248239
await debugLaunchProvider.updateTasksJson(workspaceFolder, [], new Map<string, unknown>());
249240

250241
const expectedContent = fs.readFileSync(tasksJsonFile, 'utf8');
@@ -430,11 +421,13 @@ describe('DebugLaunchProvider', () => {
430421
expect(debugLaunchProvider.activeLaunchConfiguration).toEqual(templates['multicore-start-launch']?.name);
431422
});
432423

433-
it('should include all files from launch.json.d', async () => {
424+
it('should include all configurations from .vscode.d/launch.json', async () => {
434425
const extraConfiguration = { name: 'ExtraConfig', type: 'shell', request: 'launch' };
435-
fsUtils.writeTextFile(path.join(launchJsonDir, 'extra.json'), JSON.stringify({ version: '0.2.0', configurations: [ extraConfiguration ] }, null, 4));
426+
fsUtils.writeTextFile(path.join(solutionVscodeDir, 'launch.json'), JSON.stringify({ version: '0.2.0', configurations: [ extraConfiguration ] }, null, 4));
436427

437428
const debugLaunchProvider = new DebugLaunchProviderTest();
429+
debugLaunchProvider.solutionManagerMock.getCsolution.mockReturnValue(csolutionFactory({ solutionDir: solutionFolder }));
430+
438431
const options = {
439432
processors: [],
440433
};

src/debug/debug-launch-provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export class DebugLaunchProviderImpl implements DebugLaunchProvider {
143143

144144
const solutionFolder = this.solutionManager.getCsolution()?.solutionDir ?? workspaceFolder;
145145
await this.processConfigDir(
146-
[workspaceFolder, solutionFolder],
147-
'.vscode/tasks.json.d/*.json',
146+
[solutionFolder],
147+
'.vscode.d/tasks.json',
148148
TasksJsonFile,
149149
(extraTasksJson) => {
150150
extraTasksJson.inputs.forEach(i => tasksJson.addInput(i));
@@ -209,8 +209,8 @@ export class DebugLaunchProviderImpl implements DebugLaunchProvider {
209209

210210
const solutionFolder = this.solutionManager.getCsolution()?.solutionDir ?? workspaceFolder;
211211
await this.processConfigDir(
212-
[workspaceFolder, solutionFolder],
213-
'.vscode/launch.json.d/*.json',
212+
[solutionFolder],
213+
'.vscode.d/launch.json',
214214
LaunchJsonFile,
215215
(extraLaunchJson) => extraLaunchJson.configurations.forEach(c => launchJson.addConfig(c))
216216
);

0 commit comments

Comments
 (0)