Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/solutions/solution-converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }]);
Expand Down
12 changes: 9 additions & 3 deletions src/solutions/solution-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -244,7 +249,7 @@ export class SolutionConverterImpl implements SolutionConverter {
return formattedOutput;
}

private async checkDiscoverLayers(): Promise<boolean> {
private async checkDiscoverLayers(): Promise<[boolean, string[]]> {
const outputChannel = this.outputChannelProvider.getOrCreate(manifest.CMSIS_SOLUTION_OUTPUT_CHANNEL);
this.solutionManager.getCsolution()?.setVariablesConfigurations(undefined);
// rpc method: DiscoverLayers
Expand All @@ -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 {
Expand Down
Loading