Skip to content

Commit 8b19c48

Browse files
committed
fix(cli): add missing idfTarget for non-devkit ESP32 boards #45
1 parent 5233160 commit 8b19c48

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

packages/cli/src/esp/idfProjectConfig.spec.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import { mkdtempSync, writeFileSync } from 'fs';
2+
import { tmpdir } from 'os';
3+
import path from 'path';
14
import { describe, expect, it } from 'vitest';
2-
import { createConfigForIDFProject } from './idfProjectConfig.js';
5+
import { createConfigForIDFProject, idfProjectConfig } from './idfProjectConfig.js';
36

47
describe('createConfigForIDFProject', () => {
58
it('should create a config for an IDF project', () => {
@@ -20,3 +23,50 @@ describe('createConfigForIDFProject', () => {
2023
`);
2124
});
2225
});
26+
27+
describe('idfProjectConfig', () => {
28+
function setupTempProject(boardType: string, idfTarget: string) {
29+
const dir = mkdtempSync(path.join(tmpdir(), 'wokwi-test-'));
30+
const diagramPath = path.join(dir, 'diagram.json');
31+
const projectDescPath = path.join(dir, 'project_description.json');
32+
const configPath = path.join(dir, 'wokwi.toml');
33+
writeFileSync(
34+
diagramPath,
35+
JSON.stringify({ version: 1, parts: [{ type: boardType, id: 'esp' }], connections: [] }),
36+
);
37+
writeFileSync(projectDescPath, JSON.stringify({ target: idfTarget }));
38+
return { dir, diagramPath, projectDescPath, configPath };
39+
}
40+
41+
it('should accept esp32-s3-box-3 diagram with esp32s3 IDF target', () => {
42+
const { dir, diagramPath, projectDescPath, configPath } = setupTempProject(
43+
'board-esp32-s3-box-3',
44+
'esp32s3',
45+
);
46+
47+
const result = idfProjectConfig({
48+
rootDir: dir,
49+
configPath,
50+
diagramFilePath: diagramPath,
51+
projectDescriptionPath: projectDescPath,
52+
});
53+
54+
expect(result).toBe(true);
55+
});
56+
57+
it('should reject esp32-s3-box-3 diagram with esp32 IDF target', () => {
58+
const { dir, diagramPath, projectDescPath, configPath } = setupTempProject(
59+
'board-esp32-s3-box-3',
60+
'esp32',
61+
);
62+
63+
const result = idfProjectConfig({
64+
rootDir: dir,
65+
configPath,
66+
diagramFilePath: diagramPath,
67+
projectDescriptionPath: projectDescPath,
68+
});
69+
70+
expect(result).toBe(false);
71+
});
72+
});

packages/cli/src/project/boards.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,31 @@ export const boards: IBoard[] = [
7474
title: 'ESP32-C3 Rust DevKit',
7575
type: 'board-esp32-c3-rust-1',
7676
family: 'esp32',
77+
idfTarget: 'esp32c3',
7778
serialPins: { RX: '20', TX: '21' },
7879
serialInterfaces: ['uart', 'usb-serialjtag'],
7980
},
8081
{
8182
title: 'ESP32-S3-BOX',
8283
type: 'board-esp32-s3-box',
8384
family: 'esp32',
85+
idfTarget: 'esp32s3',
8486
serialPins: { RX: 'G44', TX: 'G43' },
8587
serialInterfaces: ['uart', 'usb-serialjtag'],
8688
},
8789
{
8890
title: 'ESP32-S3-BOX-3',
8991
type: 'board-esp32-s3-box-3',
9092
family: 'esp32',
93+
idfTarget: 'esp32s3',
9194
serialPins: { RX: 'G44', TX: 'G43' },
9295
serialInterfaces: ['uart', 'usb-serialjtag'],
9396
},
9497
{
9598
title: 'M5Stack CoreS3',
9699
type: 'board-m5stack-core-s3',
97100
family: 'esp32',
101+
idfTarget: 'esp32s3',
98102
serialPins: { RX: 'G44', TX: 'G43' },
99103
serialInterfaces: ['uart', 'usb-serialjtag'],
100104
},

0 commit comments

Comments
 (0)