Skip to content

Commit 2bf147b

Browse files
author
Akos Kitta
committed
fix: make programmer optional for debug --info
Removed premature `programmer` check from the IDE. Let the CLI handle if no programmer is selected. A platform might have zero programmers. For example, `Raspberry Pi Pico boards`, `STM32`, etc. Signed-off-by: Akos Kitta <[email protected]>
1 parent 85ea487 commit 2bf147b

File tree

5 files changed

+16
-34
lines changed

5 files changed

+16
-34
lines changed

arduino-ide-extension/src/browser/contributions/debug.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,9 @@ export async function isDebugEnabled(
398398
`Failed to append boards config to the FQBN. Original FQBN was: ${fqbn}`
399399
);
400400
}
401-
if (!data.selectedProgrammer) {
402-
throw new Error(noProgrammerSelectedFor(board.name));
403-
}
404401
const params = {
405402
fqbn: fqbnWithConfig,
406-
programmer: data.selectedProgrammer.id,
403+
programmer: data.selectedProgrammer?.id,
407404
};
408405
try {
409406
const debugFqbn = await checkDebugEnabled(params);
@@ -443,13 +440,3 @@ export function debuggingNotSupported(boardName: string): string {
443440
boardName
444441
);
445442
}
446-
/**
447-
* (non-API)
448-
*/
449-
export function noProgrammerSelectedFor(boardName: string): string {
450-
return nls.localize(
451-
'arduino/debug/noProgrammerSelectedFor',
452-
"No programmer selected for '{0}'",
453-
boardName
454-
);
455-
}

arduino-ide-extension/src/common/protocol/boards-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export interface CheckDebugEnabledParams {
9595
* The FQBN might contain custom board config options. For example, `arduino:esp32:nano_nora:USBMode=hwcdc,option2=value2`.
9696
*/
9797
readonly fqbn: string;
98-
readonly programmer: string;
98+
readonly programmer?: string;
9999
}
100100

101101
export interface BoardSearch extends Searchable.Options {

arduino-ide-extension/src/node/boards-service-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class BoardsServiceImpl
178178
const req = new IsDebugSupportedRequest()
179179
.setInstance(instance)
180180
.setFqbn(fqbn)
181-
.setProgrammer(programmer);
181+
.setProgrammer(programmer ?? '');
182182
try {
183183
const debugFqbn = await new Promise<string>((resolve, reject) =>
184184
client.isDebugSupported(req, (err, resp) => {

arduino-ide-extension/src/test/browser/debug.test.ts

+13-17
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
debuggingNotSupported,
2929
isDebugEnabled,
3030
noPlatformInstalledFor,
31-
noProgrammerSelectedFor,
3231
} from '../../browser/contributions/debug';
3332
import { NotificationCenter } from '../../browser/notification-center';
3433
import { noBoardSelected } from '../../common/nls';
@@ -117,37 +116,34 @@ describe('debug', () => {
117116
);
118117
});
119118

120-
it('should error when no programmer selected', async () => {
121-
const copyData: Mutable<BoardsDataStore.Data> = deepClone(data);
122-
delete copyData.selectedProgrammer;
119+
it('should error when it fails to get the debug info from the CLI', async () => {
123120
await rejects(
124121
isDebugEnabled(
125122
board,
126123
() => boardDetails,
127-
() => copyData,
124+
() => data,
128125
(fqbn) => fqbn,
129-
unexpectedCall()
126+
() => {
127+
throw new Error('unhandled error');
128+
}
130129
),
131130
(reason) =>
132131
reason instanceof Error &&
133-
reason.message === noProgrammerSelectedFor(board.name)
132+
reason.message === debuggingNotSupported(board.name)
134133
);
135134
});
136135

137-
it('should error when it fails to get the debug info from the CLI', async () => {
138-
await rejects(
136+
it('should resolve when no programmer is selected (arduino/arduino-cli#2540)', async () => {
137+
const copyData: Mutable<BoardsDataStore.Data> = deepClone(data);
138+
delete copyData.selectedProgrammer;
139+
await doesNotReject(
139140
isDebugEnabled(
140141
board,
141142
() => boardDetails,
142-
() => data,
143+
() => copyData,
143144
(fqbn) => fqbn,
144-
() => {
145-
throw new Error('unhandled error');
146-
}
147-
),
148-
(reason) =>
149-
reason instanceof Error &&
150-
reason.message === debuggingNotSupported(board.name)
145+
async () => fqbn
146+
)
151147
);
152148
});
153149

i18n/en.json

-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@
213213
"debuggingNotSupported": "Debugging is not supported by '{0}'",
214214
"getDebugInfo": "Getting debug info...",
215215
"noPlatformInstalledFor": "Platform is not installed for '{0}'",
216-
"noProgrammerSelectedFor": "No programmer selected for '{0}'",
217216
"optimizeForDebugging": "Optimize for Debugging",
218217
"sketchIsNotCompiled": "Sketch '{0}' must be verified before starting a debug session. Please verify the sketch and start debugging again. Do you want to verify the sketch now?"
219218
},

0 commit comments

Comments
 (0)