Skip to content

Commit e89e029

Browse files
committed
Improved Error messages on board list and fixed python command issue
1 parent 3ca14b2 commit e89e029

File tree

7 files changed

+57
-29
lines changed

7 files changed

+57
-29
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ In order for this application to work correctly the zephyr require build tools n
4141

4242
See the [Install Dependecies Section of the Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html#install-dependencies)
4343

44-
For ubuntu please also install python3-venv by ```sudo apt install python3-venv```
4544

4645
## Testing
4746

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zephyr-ide",
33
"displayName": "Zephyr IDE",
44
"description": "A VS Code extension that streamlines setup, build, flashing, and debugging of Zephyr Projects",
5-
"version": "1.10.3",
5+
"version": "1.10.6",
66
"license": "Apache-2.0",
77
"publisher": "mylonics",
88
"icon": "media/logo.png",

src/project_utilities/build_selector.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,31 @@ async function getBoardlistWest(setupState: SetupState, folder: vscode.Uri | und
7474
boardRootString = " --board-root " + path.dirname(folder.fsPath);
7575
}
7676

77-
let prevError: any;
78-
if (setupState.zephyrVersion === undefined) { return; }
77+
if (setupState.zephyrVersion === undefined) {
78+
console.log("Returning because zephyrVersion is not set");
79+
return;
80+
}
7981
let res;
8082
let has_qualifiers = false;
8183
let has_revisions = false;
84+
8285
if (isVersionNumberGreater(setupState.zephyrVersion, 4, 1, 0)) {
83-
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir};{qualifiers};{revisions};{revision_default}'" + boardRootString, setupState.setupPath, setupState, false);
86+
console.log("Getting board list greater than v4.1.0");
87+
res = await executeShellCommandInPythonEnv('west boards -f "{name};{dir};{qualifiers};{revisions};{revision_default}" ' + boardRootString, setupState.setupPath, setupState, false);
8488
has_qualifiers = true;
8589
has_revisions = true;
8690
} else if (isVersionNumberGreaterEqual(setupState.zephyrVersion, 3, 7, 0)) {
87-
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir};{qualifiers}'" + boardRootString, setupState.setupPath, setupState, false);
91+
console.log("Getting board v3.7.0 and greater");
92+
res = await executeShellCommandInPythonEnv('west boards -f "{name};{dir};{qualifiers}" ' + boardRootString, setupState.setupPath, setupState, false);
8893
has_qualifiers = true;
8994
} else {
90-
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir}'" + boardRootString, setupState.setupPath, setupState, false);
95+
console.log("Getting board legacy");
96+
res = await executeShellCommandInPythonEnv('west boards -f "{name};{dir}" ' + boardRootString, setupState.setupPath, setupState, false);
9197
}
9298

93-
if (!res.stdout) {
94-
output.append(prevError);
95-
output.append(res.stderr);
99+
if (!res.stdout || res.stdout === "") {
100+
console.log("Board list error");
101+
console.log(res.stderr);
96102
vscode.window.showErrorMessage("Failed to run west boards command. See Zephyr IDE Output for error message");
97103
return;
98104
}

src/setup_utilities/west-operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export async function setupWestEnvironment(context: vscode.ExtensionContext, wsC
246246
}
247247

248248
// Install `west`
249-
let res = await executeShellCommandInPythonEnv(`python -m pip install west`, wsConfig.activeSetupState.setupPath, wsConfig.activeSetupState, true);
249+
let res = await executeShellCommandInPythonEnv(`pip install west`, wsConfig.activeSetupState.setupPath, wsConfig.activeSetupState, true);
250250
if (res.stdout) {
251251
output.append(res.stdout);
252252
output.appendLine("[SETUP] west installed");

src/test/workflow-integration.test.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ suite("Workflow Integration Test Suite", () => {
166166
);
167167
} else if (currentStep === "build-config") {
168168
const firstItemLabel = (items[0]?.label || "").toLowerCase();
169-
if (firstItemLabel.includes("zephyr directory")) {
169+
if (firstItemLabel.includes("zephyr directory") || items.some((item: any) => item.label?.toLowerCase().includes("zephyr directory"))) {
170+
console.log(' → Build Config: Selecting Zephyr Directory Only option');
170171
return (
171172
items.find((item: any) =>
172173
item.label?.toLowerCase().includes("zephyr directory")
@@ -222,19 +223,26 @@ suite("Workflow Integration Test Suite", () => {
222223
hide: () => { },
223224
dispose: () => { },
224225
show: () => {
225-
setTimeout(() => {
226-
const selectedItem = getSelection(mockQuickPick.items);
227-
if (selectedItem) {
228-
mockQuickPick.selectedItems = [selectedItem];
229-
mockQuickPick.activeItems = [selectedItem];
230-
if (mockQuickPick._onDidChangeSelectionCallback) {
231-
mockQuickPick._onDidChangeSelectionCallback([selectedItem]);
226+
const checkAndSelect = () => {
227+
if (mockQuickPick.items && mockQuickPick.items.length > 0) {
228+
const selectedItem = getSelection(mockQuickPick.items);
229+
if (selectedItem) {
230+
console.log(` → QuickPick: Selected "${selectedItem.label || selectedItem}" from ${mockQuickPick.items.length} items`);
231+
mockQuickPick.selectedItems = [selectedItem];
232+
mockQuickPick.activeItems = [selectedItem];
233+
if (mockQuickPick._onDidChangeSelectionCallback) {
234+
mockQuickPick._onDidChangeSelectionCallback([selectedItem]);
235+
}
232236
}
237+
if (mockQuickPick._onDidAcceptCallback) {
238+
mockQuickPick._onDidAcceptCallback();
239+
}
240+
} else {
241+
// Retry if items not populated yet
242+
setTimeout(checkAndSelect, 5000);
233243
}
234-
if (mockQuickPick._onDidAcceptCallback) {
235-
mockQuickPick._onDidAcceptCallback();
236-
}
237-
}, 8000);
244+
};
245+
setTimeout(checkAndSelect, 2000);
238246
},
239247
onDidTriggerButton: () => ({ dispose: () => { } }),
240248
onDidChangeSelection: (callback: any) => {
@@ -292,7 +300,7 @@ suite("Workflow Integration Test Suite", () => {
292300
if (mockInputBox._onDidAcceptCallback) {
293301
mockInputBox._onDidAcceptCallback();
294302
}
295-
}, 8000);
303+
}, 30000);
296304
},
297305
onDidAccept: (callback: any) => {
298306
mockInputBox._onDidAcceptCallback = callback;
@@ -445,6 +453,15 @@ suite("Workflow Integration Test Suite", () => {
445453
globalQuickPickCallCount = 0;
446454
globalInputBoxCallCount = 0;
447455
currentStep = "build-config";
456+
457+
// Check if west is available before attempting build config
458+
const ext = vscode.extensions.getExtension("mylonics.zephyr-ide");
459+
const wsConfig = ext?.exports?.getWorkspaceConfig();
460+
if (!wsConfig?.initialSetupComplete) {
461+
console.log("⚠️ Setup not complete, retrying in 10 seconds...");
462+
await new Promise((resolve) => setTimeout(resolve, 10000));
463+
}
464+
448465
result = await vscode.commands.executeCommand("zephyr-ide.add-build");
449466
assert.ok(result, "Build configuration should succeed");
450467

src/utilities/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export function getPythonVenvBinaryFolder(setupState: SetupState) {
7070
return '';
7171
}
7272

73+
function generatePythonModuleCmdString(setupState: SetupState, cmd: string) {
74+
return path.join(getPythonVenvBinaryFolder(setupState), "python -m ", cmd);
75+
}
76+
7377
export async function getRootPathFs(first = false) {
7478
let rootPath = await getRootPath(first);
7579
if (rootPath && rootPath.fsPath) {
@@ -169,9 +173,9 @@ async function executeTask(task: vscode.Task) {
169173
export async function executeTaskHelperInPythonEnv(setupState: SetupState | undefined, taskName: string, cmd: string, cwd: string | undefined) {
170174
if (setupState && isMacOS()) {
171175
let newCmd = path.join(getPythonVenvBinaryFolder(setupState), cmd);
172-
return executeTaskHelper(taskName, newCmd, cwd);
176+
return await executeTaskHelper(taskName, newCmd, cwd);
173177
} else {
174-
return executeTaskHelper(taskName, cmd, cwd);
178+
return await executeTaskHelper(taskName, cmd, cwd);
175179
}
176180
}
177181

@@ -197,7 +201,8 @@ export async function executeTaskHelper(taskName: string, cmd: string, cwd: stri
197201
}
198202

199203
export async function executeShellCommandInPythonEnv(cmd: string, cwd: string, setupState: SetupState, display_error = true) {
200-
let newCmd = path.join(getPythonVenvBinaryFolder(setupState), cmd);
204+
let newCmd = generatePythonModuleCmdString(setupState, cmd);
205+
console.log("Running new python command", JSON.stringify(newCmd));
201206
return executeShellCommand(newCmd, cwd, display_error);
202207
};
203208

@@ -212,6 +217,7 @@ export async function executeShellCommand(cmd: string, cwd: string, display_erro
212217
if (display_error) {
213218
output.append(reason);
214219
}
220+
console.log(JSON.stringify(reason));
215221
return { stdout: undefined, stderr: reason.stderr };
216222
}
217223
);

0 commit comments

Comments
 (0)