feat(config): add Scaffolding.Boards typed input with 6 defaults
This commit is contained in:
@@ -61,6 +61,16 @@ type RenodeConfig struct {
|
||||
Platforms []RenodePlatform `yaml:"platforms"`
|
||||
}
|
||||
|
||||
type Board struct {
|
||||
Name string `yaml:"name"`
|
||||
FQBN string `yaml:"fqbn"`
|
||||
Template string `yaml:"template"`
|
||||
}
|
||||
|
||||
type Scaffolding struct {
|
||||
Boards []Board `yaml:"boards"`
|
||||
}
|
||||
|
||||
// Config is the fully-resolved runtime configuration.
|
||||
type Config struct {
|
||||
Version int `yaml:"version"`
|
||||
@@ -76,6 +86,7 @@ type Config struct {
|
||||
ShellConfig ShellConfigSection `yaml:"shell_config"`
|
||||
Neovim NeovimConfig `yaml:"neovim"`
|
||||
Renode RenodeConfig `yaml:"renode"`
|
||||
Scaffolding Scaffolding `yaml:"scaffolding"`
|
||||
}
|
||||
|
||||
const currentVersion = 1
|
||||
@@ -161,5 +172,8 @@ func merge(base, over Config) Config {
|
||||
if over.Renode.WokwiVersion != "" || len(over.Renode.Platforms) > 0 {
|
||||
out.Renode = over.Renode
|
||||
}
|
||||
if len(over.Scaffolding.Boards) > 0 {
|
||||
out.Scaffolding = over.Scaffolding
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -108,3 +108,26 @@ func TestLoadRejectsUnknownVersion(t *testing.T) {
|
||||
t.Fatal("expected version error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultsCarryScaffoldingBoards(t *testing.T) {
|
||||
cfg, err := Load("/nonexistent/overlay.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(cfg.Scaffolding.Boards) < 6 {
|
||||
t.Fatalf("want >= 6 boards, got %d", len(cfg.Scaffolding.Boards))
|
||||
}
|
||||
want := map[string]string{
|
||||
"uno": "arduino:avr:uno", "mega": "arduino:avr:mega", "nano": "arduino:avr:nano",
|
||||
"esp32": "esp32:esp32:esp32", "esp32s3": "esp32:esp32:esp32s3", "esp8266": "esp8266:esp8266:nodemcuv2",
|
||||
}
|
||||
got := map[string]string{}
|
||||
for _, b := range cfg.Scaffolding.Boards {
|
||||
got[b.Name] = b.FQBN
|
||||
}
|
||||
for name, fqbn := range want {
|
||||
if got[name] != fqbn {
|
||||
t.Errorf("board %q: got fqbn %q, want %q", name, got[name], fqbn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +97,12 @@ renode:
|
||||
- name: nrf52840
|
||||
repl_path: "platforms/cpus/nrf52840.repl"
|
||||
machine: "nRF52840"
|
||||
|
||||
scaffolding:
|
||||
boards:
|
||||
- {name: uno, fqbn: "arduino:avr:uno", template: uno}
|
||||
- {name: mega, fqbn: "arduino:avr:mega", template: mega}
|
||||
- {name: nano, fqbn: "arduino:avr:nano", template: nano}
|
||||
- {name: esp32, fqbn: "esp32:esp32:esp32", template: esp32}
|
||||
- {name: esp32s3, fqbn: "esp32:esp32:esp32s3", template: esp32s3}
|
||||
- {name: esp8266, fqbn: "esp8266:esp8266:nodemcuv2", template: esp8266}
|
||||
|
||||
Reference in New Issue
Block a user