Skip to content

Commit dc012f4

Browse files
authored
Fixing test errors (#124)
* Attempting to fix test errors * another attempt that probably wont work * Added some small delays * More tries to fix * Added explicit check if sdk is installed * Fixing up a few changes * More test fixes * Maybe now the tests are fixed * Fixed incorrect command name * Fixed multiple reprints of packages installed completed * Fixed sdk interactions being missed * Moved sdk mock ui bits back into workspace setup: * A few more minor changes
1 parent fcb995d commit dc012f4

13 files changed

+58
-52
lines changed

.github/workflows/prerelease-vscode.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- run: npm --prefix server ci
2121
- run: npm --prefix client ci
2222
- run: npm version patch --no-git-tag-version
23-
- run: npm version patch --preid=alpha --no-git-tag-version
2423
- uses: lannonbr/vsce-action@4.0.0
2524
with:
2625
args: "publish --pre-release -p $VSCE_TOKEN"

.vscode-test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { join } from 'path';
44
import { mkdirSync } from 'fs';
55

66
// Create a temporary test workspace
7-
const testWorkspace = join(tmpdir(), 'zephyr-ide-test-workspace-' + Date.now());
7+
const testWorkspace = join(tmpdir(), 'zide-spc-' + Date.now());
88
mkdirSync(testWorkspace, { recursive: true });
99

1010
export default defineConfig({

docs/TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Add tests to `src/test/standard-workspace.test.ts` for standard workflow validat
118118

119119
```typescript
120120
test('New Workflow Feature', async function() {
121-
this.timeout(420000);
121+
this.timeout(620000);
122122

123123
const uiMock = new UIMockInterface();
124124
uiMock.activate();
@@ -142,7 +142,7 @@ Add tests to `src/test/west-git-workspace.test.ts` for git-based workflows:
142142

143143
```typescript
144144
test('Git Workflow Feature', async function() {
145-
this.timeout(420000);
145+
this.timeout(620000);
146146

147147
const gitUiMock = new UIMockInterface();
148148
gitUiMock.activate();

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.15",
5+
"version": "1.10.16",
66
"license": "Apache-2.0",
77
"publisher": "mylonics",
88
"icon": "media/logo.png",

src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,14 @@ export async function activate(context: vscode.ExtensionContext) {
12331233

12341234
context.subscriptions.push(
12351235
vscode.commands.registerCommand("zephyr-ide.install-sdk", async () => {
1236-
return await installSDKInteractive(wsConfig, globalConfig, context);
1236+
let ret = await installSDKInteractive(wsConfig, globalConfig, context);
1237+
return ret;
1238+
})
1239+
);
1240+
1241+
context.subscriptions.push(
1242+
vscode.commands.registerCommand("zephyr-ide.is-sdk-installed", async () => {
1243+
return globalConfig.sdkInstalled;
12371244
})
12381245
);
12391246

src/setup_utilities/west-operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export async function westUpdate(context: vscode.ExtensionContext, wsConfig: Wor
117117
wsConfig.activeSetupState.zephyrVersion = undefined;
118118
saveSetupState(context, wsConfig, globalConfig);
119119

120-
let cmd = `west update`;
120+
let cmd = `west update --narrow`;
121121
let westUpdateRes = await executeTaskHelperInPythonEnv(wsConfig.activeSetupState, "Zephyr IDE: West Update", cmd, wsConfig.activeSetupState.setupPath);
122122

123123
if (!westUpdateRes) {

src/setup_utilities/workspace-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function workspaceSetupFromWestGit(context: vscode.ExtensionContext
206206
const gitUrl = await vscode.window.showInputBox({
207207
prompt: "Enter the Git repository URL for the West workspace",
208208
placeHolder:
209-
"https://github.com/zephyrproject-rtos/example-application.git",
209+
"https://github.com/zephyrproject-rtos/example-application",
210210
ignoreFocusOut: true,
211211
validateInput: (value) => {
212212
if (!value || value.trim() === "") {

src/test/open-current-directory.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ suite("Open Current Directory Test Suite", () => {
5252
const existingWorkspace =
5353
vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
5454
testWorkspaceDir = existingWorkspace
55-
? path.join(existingWorkspace, "open-current-directory-test")
56-
: path.join(os.tmpdir(), "open-current-directory-test-" + Date.now());
55+
? path.join(existingWorkspace, "curr-dir")
56+
: path.join(os.tmpdir(), "curr-dir-" + Date.now());
5757

5858
await fs.ensureDir(testWorkspaceDir);
5959

@@ -102,7 +102,7 @@ suite("Open Current Directory Test Suite", () => {
102102
});
103103

104104
test("Open Current Directory: Git Setup → Detect West.yml → Build", async function () {
105-
this.timeout(420000);
105+
this.timeout(620000);
106106

107107
console.log("🚀 Starting open current directory test...");
108108

@@ -120,7 +120,11 @@ suite("Open Current Directory Test Suite", () => {
120120
console.log("🏗️ Step 1: Setting up workspace from git with west.yml detection...");
121121
// Prime the mock interface for git setup with branch argument
122122
uiMock.primeInteractions([
123-
{ type: 'input', value: '--branch no_west_folder -- https://github.com/mylonics/zephyr-ide-samples.git', description: 'Enter git clone string with branch' }
123+
{ type: 'input', value: '--branch no_west_folder -- https://github.com/mylonics/zephyr-ide-samples.git', description: 'Enter git clone string with branch' },
124+
{ type: 'quickpick', value: 'local-west', description: 'Choose Use Local West Workspace option' },
125+
{ type: 'quickpick', value: 'automatic', description: 'Select SDK Version' },
126+
{ type: 'quickpick', value: 'select specific', description: 'Select specific toolchains' },
127+
{ type: 'quickpick', value: 'arm-zephyr-eabi', description: 'Select ARM toolchain', multiSelect: true }
124128
]);
125129

126130
let result = await vscode.commands.executeCommand(
@@ -129,10 +133,6 @@ suite("Open Current Directory Test Suite", () => {
129133
assert.ok(result, "Git workspace setup should succeed");
130134

131135
console.log("🔍 Step 2: Choosing detected west.yml file...");
132-
// Prime the mock interface for west.yml detection prompt
133-
uiMock.primeInteractions([
134-
{ type: 'quickpick', value: 'local-west', description: 'Choose Use Local West Workspace option' }
135-
]);
136136

137137
await monitorWorkspaceSetup("open current directory");
138138

src/test/standard-workspace.test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ suite("Standard Workspace Test Suite", () => {
6262
const existingWorkspace =
6363
vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
6464
testWorkspaceDir = existingWorkspace
65-
? path.join(existingWorkspace, "zephyr-workflow-test")
66-
: path.join(os.tmpdir(), "zephyr-workflow-test-" + Date.now());
65+
? path.join(existingWorkspace, "std")
66+
: path.join(os.tmpdir(), "std-" + Date.now());
6767

6868
await fs.ensureDir(testWorkspaceDir);
6969

@@ -112,7 +112,7 @@ suite("Standard Workspace Test Suite", () => {
112112
});
113113

114114
test("Complete Workflow: Dependencies → Setup → Project → Build → Execute", async function () {
115-
this.timeout(420000);
115+
this.timeout(620000);
116116

117117
console.log("🚀 Starting workflow test...");
118118

@@ -153,12 +153,6 @@ suite("Standard Workspace Test Suite", () => {
153153

154154
await monitorWorkspaceSetup();
155155

156-
console.log("⚙️ Step 3: Installing SDK...");
157-
// Prime the mock interface for SDK installation interactions
158-
159-
//result = await vscode.commands.executeCommand("zephyr-ide.install-sdk");
160-
//assert.ok(result, "SDK installation should succeed");
161-
162156
console.log("📁 Step 4: Creating project from template...");
163157
// Prime the mock interface for project creation interactions
164158
uiMock.primeInteractions([
@@ -183,6 +177,7 @@ suite("Standard Workspace Test Suite", () => {
183177
result = await vscode.commands.executeCommand("zephyr-ide.add-build");
184178
assert.ok(result, "Build configuration should succeed");
185179

180+
await new Promise((resolve) => setTimeout(resolve, 10000));
186181
console.log("⚡ Step 6: Executing build...");
187182
result = await vscode.commands.executeCommand("zephyr-ide.build");
188183
assert.ok(result, "Build execution should succeed");

src/test/test-runner.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const execAsync = util.promisify(cp.exec);
2727
* Check if build dependencies are available using the extension's built-in check
2828
*/
2929
export async function checkBuildDependencies(
30-
context: vscode.ExtensionContext,
31-
wsConfig: WorkspaceConfig,
30+
context: vscode.ExtensionContext,
31+
wsConfig: WorkspaceConfig,
3232
globalConfig: GlobalConfig
3333
): Promise<boolean> {
3434
try {
3535
// Use the extension's own build dependency checker
3636
const result = await checkIfToolsAvailable(context, wsConfig, globalConfig, false);
37-
37+
3838
if (result) {
3939
console.log('✓ Build dependencies are available');
4040
return true;
@@ -57,7 +57,7 @@ export async function checkZephyrToolsAvailable(): Promise<boolean> {
5757
// Just check for basic tools as a fallback
5858
await execAsync('python --version');
5959
await execAsync('cmake --version');
60-
60+
6161
console.log('✓ Basic development tools are available');
6262
return true;
6363
} catch (error) {
@@ -112,8 +112,9 @@ export async function monitorWorkspaceSetup(setupType: string = "workspace"): Pr
112112
let pythonEnvironmentSetup = false;
113113
let westUpdated = false;
114114
let packagesInstalled = false;
115+
let sdkInstalled = false;
115116

116-
while (!packagesInstalled) {
117+
while (!sdkInstalled) {
117118
const extension = vscode.extensions.getExtension("mylonics.zephyr-ide");
118119
let wsConfig = null;
119120

@@ -137,18 +138,23 @@ export async function monitorWorkspaceSetup(setupType: string = "workspace"): Pr
137138
pythonEnvironmentSetup = true;
138139
}
139140

140-
if (wsConfig.activeSetupState?.packagesInstalled) {
141+
if (!packagesInstalled && wsConfig.activeSetupState?.packagesInstalled) {
141142
packagesInstalled = true;
142143
console.log(" ✅ Packages installed completed");
144+
}
145+
146+
if (packagesInstalled && await vscode.commands.executeCommand("zephyr-ide.is-sdk-installed")) {
147+
sdkInstalled = true;
148+
console.log(" ✅ SDK installed");
143149
console.log(`🎉 All ${setupType} setup stages completed!`);
144150
break;
145151
}
146152
}
147153

148154
// Progress update every 30 seconds
149155
if (waitTime % 30000 === 0 && waitTime > 0) {
150-
const completedStages = [initialSetupComplete, pythonEnvironmentSetup, westUpdated, packagesInstalled].filter(Boolean).length;
151-
console.log(`⏳ ${setupType} setup in progress... (${waitTime / 1000}s elapsed, ${completedStages}/4 stages completed)`);
156+
const completedStages = [initialSetupComplete, pythonEnvironmentSetup, westUpdated, packagesInstalled, sdkInstalled].filter(Boolean).length;
157+
console.log(`⏳ ${setupType} setup in progress... (${waitTime / 1000}s elapsed, ${completedStages}/5 stages completed)`);
152158
}
153159

154160
await new Promise((resolve) => setTimeout(resolve, checkInterval));

0 commit comments

Comments
 (0)