Extract attach-bsdl into core; add it to the wx GUI.
Second editing op into the wx frontend. Extract the logic (parse the .bsd,
apply it to the part, record bsdl_path) into core/app/edit.hpp::attach_bsdl
(Part*, path) -> {ok, error, entity, bound, unbound, ports_total}, failing
without mutation when the file can't be parsed.
The TUI `attach-bsdl` command now renders that result (output unchanged); the
wx GUI gains an Edit ▸ Attach BSDL… menu reusing PickPart() + a .bsd file
dialog. Prune the now-dead bsdl_model include from commands.cpp.
tests/test_edit.cpp: parse failure leaves the part untouched; null part. The
success path is covered by a batch run (entity + bound/total ports). 381 core
assertions green; tui + wx build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,3 +37,20 @@ TEST_CASE("set_connector_type on a null part fails cleanly") {
|
||||
CHECK_FALSE(r.ok);
|
||||
CHECK_FALSE(r.error.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("attach_bsdl reports a parse failure without mutating the part") {
|
||||
Part p("J1");
|
||||
p.add(new Pin("1"));
|
||||
|
||||
app::AttachBsdlResult r = app::attach_bsdl(&p, "/nonexistent-xyz/none.bsd");
|
||||
|
||||
CHECK_FALSE(r.ok);
|
||||
CHECK(r.error.find("cannot parse") != std::string::npos);
|
||||
CHECK(p.bsdl_path.empty()); // failure leaves the part untouched
|
||||
}
|
||||
|
||||
TEST_CASE("attach_bsdl on a null part fails cleanly") {
|
||||
app::AttachBsdlResult r = app::attach_bsdl(nullptr, "x.bsd");
|
||||
CHECK_FALSE(r.ok);
|
||||
CHECK_FALSE(r.error.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user