diff --git a/src/solutions/solution-converter.test.ts b/src/solutions/solution-converter.test.ts index 8072c412..366de7e4 100644 --- a/src/solutions/solution-converter.test.ts +++ b/src/solutions/solution-converter.test.ts @@ -293,6 +293,26 @@ describe('SolutionConverter', () => { ); }); + it('reports discoverLayers failure through toolsOutputMessages', async () => { + mockCsolutionService.convertSolution.mockResolvedValue({ + success: false, + undefinedLayers: ['$Board-Layer'], + }); + mockCsolutionService.discoverLayers.mockResolvedValue({ + success: false, + message: 'No compatible software layer found.' + }); + await fireAndWaitForConversion(); + + expect(completedListener).toHaveBeenCalledWith( + expect.objectContaining({ + severity: 'error', + detection: false, + toolsOutputMessages: expect.arrayContaining(['error csolution: No compatible software layer found.']), + }) + ); + }); + it('run solution convert and check whether to update compile commands', async () => { const mockRunCbuildSetup = jest.spyOn(compileCommandsGenerator, 'runCbuildSetup').mockResolvedValue([true,[]]); mockCSolution.getContextDescriptors = jest.fn().mockReturnValue([{ displayName: 'context' }]); diff --git a/src/solutions/solution-converter.ts b/src/solutions/solution-converter.ts index c745aefa..d935cef5 100644 --- a/src/solutions/solution-converter.ts +++ b/src/solutions/solution-converter.ts @@ -162,7 +162,12 @@ export class SolutionConverterImpl implements SolutionConverter { // compilers and variables detection handling: apply select-compiler and discover layer configurations if any csolution?.setSelectCompiler(convertResult.selectCompiler); - detection = (!!convertResult.undefinedLayers && await this.checkDiscoverLayers()) || !!convertResult.selectCompiler; + if (convertResult.undefinedLayers) { + const [discoverLayersDetected, discoverLayersOutput] = await this.checkDiscoverLayers(); + detection = discoverLayersDetected; + toolsOutputMessages = toolsOutputMessages.concat(discoverLayersOutput); + } + detection = detection || !!convertResult.selectCompiler; } let logResult = undefined; @@ -244,7 +249,7 @@ export class SolutionConverterImpl implements SolutionConverter { return formattedOutput; } - private async checkDiscoverLayers(): Promise { + private async checkDiscoverLayers(): Promise<[boolean, string[]]> { const outputChannel = this.outputChannelProvider.getOrCreate(manifest.CMSIS_SOLUTION_OUTPUT_CHANNEL); this.solutionManager.getCsolution()?.setVariablesConfigurations(undefined); // rpc method: DiscoverLayers @@ -257,7 +262,8 @@ export class SolutionConverterImpl implements SolutionConverter { } ) as rpc.DiscoverLayersInfo; this.solutionManager.getCsolution()?.setVariablesConfigurations(result.configurations); - return result.success; + const formattedOutput = !result.success && result.message ? [`error csolution: ${result.message.trim()}`] : []; + return [result.success, formattedOutput]; } private getSeverity(messages: rpc.LogMessages, lines?: string[]): Severity {