Skip to content

Commit 08f6a66

Browse files
committed
Forcing Update with narrow to speed up tests
1 parent eeb098f commit 08f6a66

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/extension.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { checkIfToolsAvailable } from "./setup_utilities/tools-validation";
8080
import {
8181
postWorkspaceSetup,
8282
westInit,
83+
setForceNarrowUpdateForTest,
8384
setupWestEnvironment,
8485
westUpdateWithRequirements,
8586
} from "./setup_utilities/west-operations";
@@ -1362,6 +1363,14 @@ export async function activate(context: vscode.ExtensionContext) {
13621363
)
13631364
);
13641365

1366+
// Test-only command: update-with-narrow (not in package.json)
1367+
context.subscriptions.push(
1368+
vscode.commands.registerCommand('zephyr-ide.update-with-narrow', async () => {
1369+
setForceNarrowUpdateForTest(true);
1370+
vscode.window.showInformationMessage('Zephyr IDE: Forced useNarrowUpdate for westUpdate (test only, variable override).');
1371+
})
1372+
);
1373+
13651374
context.subscriptions.push(
13661375
vscode.commands.registerCommand("zephyr-ide.shell_test", async () => {
13671376
output.show();

src/setup_utilities/west-operations.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ import { WorkspaceConfig, GlobalConfig, SetupState } from "./types";
2626
import { saveSetupState, setSetupState, setWorkspaceState } from "./state-management";
2727
import { pathdivider } from "./tools-validation";
2828

29+
// Test-only override for narrow update
30+
let forceNarrowUpdateForTest = false;
31+
32+
export function setForceNarrowUpdateForTest(value: boolean) {
33+
forceNarrowUpdateForTest = value;
34+
}
35+
2936
let python = os.platform() === "linux" ? "python3" : "python";
3037

3138
export function checkWestInit(setupState: SetupState) {
@@ -118,9 +125,12 @@ export async function westUpdate(context: vscode.ExtensionContext, wsConfig: Wor
118125
wsConfig.activeSetupState.zephyrVersion = undefined;
119126
saveSetupState(context, wsConfig, globalConfig);
120127

121-
// Read config option from settings.json
128+
// Read config option from settings.json, but allow test override
122129
const configuration = vscode.workspace.getConfiguration('zephyr-ide');
123-
const useNarrowUpdate = configuration.get<boolean>('westNarrowUpdate', false); // default false
130+
let useNarrowUpdate = configuration.get<boolean>('westNarrowUpdate', false);
131+
if (forceNarrowUpdateForTest) {
132+
useNarrowUpdate = true;
133+
}
124134
let cmd = useNarrowUpdate ? 'west update --narrow' : 'west update';
125135
let westUpdateRes = await executeTaskHelperInPythonEnv(wsConfig.activeSetupState, "Zephyr IDE: West Update", cmd, wsConfig.activeSetupState.setupPath);
126136

src/test/test-runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export async function executeWorkspaceCommand(
227227
commandId: string,
228228
successMessage: string
229229
): Promise<void> {
230+
await vscode.commands.executeCommand("zephyr-ide.update-with-narrow");
230231
uiMock.primeInteractions(interactions);
231232

232233
const result = await vscode.commands.executeCommand(commandId);

0 commit comments

Comments
 (0)