Skip to content

Commit 362f321

Browse files
committed
Show discoverLayers errors in Problems
1 parent 1a4f53f commit 362f321

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

src/solutions/solution-converter.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,26 @@ describe('SolutionConverter', () => {
293293
);
294294
});
295295

296+
it('reports discoverLayers failure through toolsOutputMessages', async () => {
297+
mockCsolutionService.convertSolution.mockResolvedValue({
298+
success: false,
299+
undefinedLayers: ['$Board-Layer'],
300+
});
301+
mockCsolutionService.discoverLayers.mockResolvedValue({
302+
success: false,
303+
message: 'No compatible software layer found.'
304+
});
305+
await fireAndWaitForConversion();
306+
307+
expect(completedListener).toHaveBeenCalledWith(
308+
expect.objectContaining({
309+
severity: 'error',
310+
detection: false,
311+
toolsOutputMessages: expect.arrayContaining(['error csolution: No compatible software layer found.']),
312+
})
313+
);
314+
});
315+
296316
it('run solution convert and check whether to update compile commands', async () => {
297317
const mockRunCbuildSetup = jest.spyOn(compileCommandsGenerator, 'runCbuildSetup').mockResolvedValue([true,[]]);
298318
mockCSolution.getContextDescriptors = jest.fn().mockReturnValue([{ displayName: 'context' }]);

src/solutions/solution-converter.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ export class SolutionConverterImpl implements SolutionConverter {
162162

163163
// compilers and variables detection handling: apply select-compiler and discover layer configurations if any
164164
csolution?.setSelectCompiler(convertResult.selectCompiler);
165-
detection = (!!convertResult.undefinedLayers && await this.checkDiscoverLayers()) || !!convertResult.selectCompiler;
165+
if (convertResult.undefinedLayers) {
166+
const [discoverLayersDetected, discoverLayersOutput] = await this.checkDiscoverLayers();
167+
detection = discoverLayersDetected;
168+
toolsOutputMessages = toolsOutputMessages.concat(discoverLayersOutput);
169+
}
170+
detection = detection || !!convertResult.selectCompiler;
166171
}
167172

168173
let logResult = undefined;
@@ -244,7 +249,7 @@ export class SolutionConverterImpl implements SolutionConverter {
244249
return formattedOutput;
245250
}
246251

247-
private async checkDiscoverLayers(): Promise<boolean> {
252+
private async checkDiscoverLayers(): Promise<[boolean, string[]]> {
248253
const outputChannel = this.outputChannelProvider.getOrCreate(manifest.CMSIS_SOLUTION_OUTPUT_CHANNEL);
249254
this.solutionManager.getCsolution()?.setVariablesConfigurations(undefined);
250255
// rpc method: DiscoverLayers
@@ -257,7 +262,10 @@ export class SolutionConverterImpl implements SolutionConverter {
257262
}
258263
) as rpc.DiscoverLayersInfo;
259264
this.solutionManager.getCsolution()?.setVariablesConfigurations(result.configurations);
260-
return result.success;
265+
266+
const formattedOutput = !result.success && result.message ? [`error csolution: ${result.message}`] : [];
267+
268+
return [result.success, formattedOutput];
261269
}
262270

263271
private getSeverity(messages: rpc.LogMessages, lines?: string[]): Severity {

0 commit comments

Comments
 (0)