app
SOLIDWORKS Bridge
Public Made by Adomby adom
Launch, model and quit SOLIDWORKS from any Adom container. Nothing is ever lost.
main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
//! ISSUE #1 on adom/solidworks-bridge (Michael, 2026-10-13, SOLIDWORKS 2021):
//! "19 boss extrudes and 3 cuts for a part that takes 4-5 features by hand".
//! The 0.10.0 DSL — offset/face sketches, cut direction, multi-profile
//! sketches, appearance, documented conventions, fillet/chamfer/shell/patterns
//! — and the brick he cares about, examples/lego-2x4.json, in 4 features.
//!
//! EVERYTHING HERE RUNS IN THE SIMULATOR. The geometry it asserts is the mock's
//! arithmetic model (src/comhost/mock_model.rs), NOT a SOLIDWORKS measurement:
//! the brick is UNMEASURED until it is run live.
mod common;
use common::{Bridge, TempDir};
use serde_json::{json, Value};
fn s(v: &Value) -> String {
serde_json::to_string_pretty(v).unwrap_or_default()
}
fn boot(tag: &str) -> (Bridge, TempDir) {
let machine = TempDir::new(tag);
std::fs::write(machine.join("windows.json"), "[]").unwrap();
let b = Bridge::start_with(&[("SWX_LAUNCH_FAKE_DIR", &machine.path())]);
(b, machine)
}
fn lego() -> Value {
let p = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("examples/lego-2x4.json");
serde_json::from_str(&std::fs::read_to_string(p).expect("examples/lego-2x4.json")).expect("it parses")
}
fn near(a: &Value, b: f64, tol: f64) -> bool {
a.as_f64().map(|x| (x - b).abs() <= tol).unwrap_or(false)
}
#[test]
fn the_lego_brick_is_four_features_with_the_new_ops() {
let (b, _m) = boot("issue1-lego");
let brick = lego();
let r = b.call("swx_run_script", json!({"script": brick["script"]}));
check!(b, "the brick script runs end to end", r["success"] == true, s(&r));
let steps = r["steps"].as_array().cloned().unwrap_or_default();
let ops: Vec<&str> = steps.iter().map(|st| st["op"].as_str().unwrap_or("")).collect();
check!(
b,
"the op sequence: block, hollow cut, tubes (one multi-profile sketch), studs (offset plane)",
ops == ["new_part", "sketch_rect", "extrude", "sketch_rect", "cut", "sketch", "extrude", "sketch", "extrude", "set_material", "set_appearance", "set_prop"],
format!("{ops:?}")
);
let features: Vec<String> = steps.iter().filter_map(|st| st["result"]["feature"].as_str().map(String::from)).collect();
check!(
b,
"<= 6 features (Michael's build took 22), every one non-null",
features.len() == 4 && features.len() <= 6 && features == ["Boss-Extrude1", "Cut-Extrude1", "Boss-Extrude2", "Boss-Extrude3"],
format!("{features:?}")
);
check!(
b,
"the studs' sketch resolved onto a plane 9.6 mm above Top Plane, made by the script",
steps[7]["result"]["resolvedPlane"]["offsetMm"].as_f64().map(|v| (v - 9.6).abs() < 1e-9).unwrap_or(false)
&& steps[7]["result"]["createdPlane"].is_string(),
s(&steps[7])
);
check!(
b,
"the hollow is cut UPWARD from Top Plane (reverse:true): 0 .. 8.6 mm",
near(&steps[4]["result"]["spanMm"][0], 0.0, 1e-9) && near(&steps[4]["result"]["spanMm"][1], 8.6, 1e-9),
s(&steps[4])
);
let ib = b.call("swx_inspect_bodies", json!({}));
let body = &ib["bodies"][0];
check!(
b,
"ONE solid body, 31.8 x 11.3 x 15.8 mm, centred on the origin, on +Y (SIMULATED geometry)",
ib["bodyCount"] == 1 && near(&body["sizeMm"]["x"], 31.8, 1e-6) && near(&body["sizeMm"]["y"], 11.3, 1e-6)
&& near(&body["sizeMm"]["z"], 15.8, 1e-6) && near(&body["bbox"]["minMm"][0], -15.9, 1e-6) && near(&body["bbox"]["minMm"][1], 0.0, 1e-6),
s(body)
);
check!(
b,
"volume 2073.3615 mm³ by the script's arithmetic — the very volume SOLIDWORKS 2021 measured for Michael's 22-feature brick (2073.3615208) — simulated here, not measured",
near(&body["volumeMm3"], 2073.3615, 0.001),
s(body)
);
check!(
b,
"red, read back; ABS density applied to the mass",
body["appearanceRgb"] == json!([200, 0, 0]) && body["densityKgM3"] == 1020.0
&& near(&body["massKg"], 2073.3615e-9 * 1020.0, 1e-8),
s(body)
);
check!(
b,
"the example says where it was MEASURED: SOLIDWORKS 2026 and 2021 (community), identical",
brick["expected"]["status"].as_str().map(|t| t.starts_with("MEASURED on SOLIDWORKS 2026") && t.contains("SOLIDWORKS 2021") && t.contains("community")).unwrap_or(false),
s(&brick["expected"])
);
}
#[test]
fn a_cut_or_extrude_that_builds_nothing_is_an_error_never_a_silent_success() {
let (b, _m) = boot("issue1-null");
// A cut with no body at all: SOLIDWORKS has nothing to cut.
let r = b.call("swx_run_script", json!({"script": [
{"op": "new_part"},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 10, "heightMm": 10},
{"op": "cut", "depthMm": 5}
]}));
check!(
b,
"a cut that returns no feature fails the step, by number, saying nothing was cut",
r["success"] == false && r["error"].as_str().unwrap_or("").contains("step 3 (cut)"),
s(&r)
);
// The measured case: SOLIDWORKS returns feature:null (simulated).
std::fs::write(b.scratch.join("mock-feature-null-cut"), "").unwrap();
let r = b.call("swx_run_script", json!({"script": [
{"op": "new_part"},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 10, "heightMm": 10, "anchor": "center"},
{"op": "extrude", "depthMm": 5},
{"op": "sketch_circle", "plane": "Top Plane", "radiusMm": 2},
{"op": "cut", "throughAll": true}
]}));
check!(
b,
"feature:null is an ERROR naming the step and the direction rule — never success:true with nothing removed",
r["success"] == false && r["error"].as_str().unwrap_or("").contains("step 5 (cut)")
&& r["error"].as_str().unwrap_or("").contains("normal"),
s(&r)
);
}
#[test]
fn faces_offsets_both_ways_and_rings_build_what_they_say() {
let (b, _m) = boot("issue1-ops");
let r = b.call("swx_run_script", json!({"script": [
{"op": "new_part"},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 20, "heightMm": 20, "anchor": "center"},
{"op": "extrude", "depthMm": 10},
// a boss on the TOP FACE, found by a point on it
{"op": "sketch_circle", "face": {"atPointMm": [0, 10, 0]}, "radiusMm": 3},
{"op": "extrude", "depthMm": 2},
// a ring, both directions from Front Plane
{"op": "sketch", "plane": "Front Plane", "entities": [{"circle": {"radiusMm": 4, "centerMm": [0, 5]}}, {"circle": {"radiusMm": 2, "centerMm": [0, 5]}}]},
{"op": "extrude", "depthMm": 15, "direction": "both", "depth2Mm": 15},
{"op": "fillet", "radiusMm": 0.5, "edges": {"allOfFeature": "last"}},
{"op": "chamfer", "distanceMm": 0.5, "edges": {"atPointsMm": [[10, 0, 5]]}},
{"op": "linear_pattern", "feature": "Boss-Extrude2", "directions": [{"axis": "x", "count": 2, "spacingMm": 6}]},
{"op": "circular_pattern", "feature": "Boss-Extrude2", "axis": "y", "count": 4},
{"op": "shell", "thicknessMm": 1, "removeFacesAtPointsMm": [[5, 0, 5]]}
]}));
check!(b, "every new op runs", r["success"] == true, s(&r));
let st = r["steps"].as_array().cloned().unwrap_or_default();
check!(
b,
"the face resolved to the plane 10 mm above Top Plane",
st[3]["result"]["resolvedPlane"]["offsetFrom"] == "Top Plane" && near(&st[3]["result"]["resolvedPlane"]["offsetMm"], 10.0, 1e-9),
s(&st[3])
);
check!(
b,
"both directions: -15 .. +15 mm about Front Plane, and the two circles are a RING (area pi(4²-2²))",
near(&st[6]["result"]["spanMm"][0], -15.0, 1e-9) && near(&st[6]["result"]["spanMm"][1], 15.0, 1e-9)
&& near(&st[5]["result"]["profileAreaMm2"], std::f64::consts::PI * 12.0, 1e-6),
format!("{}\n{}", s(&st[5]), s(&st[6]))
);
check!(
b,
"fillet, chamfer, both patterns and the shell each report a feature",
["Fillet1", "Chamfer1", "LPattern1", "CirPattern1", "Shell1"].iter().enumerate().all(|(i, f)| st[7 + i]["result"]["feature"] == *f),
s(&r["steps"])
);
check!(b, "the fillet took the edges of the feature before it", st[7]["result"]["edges"]["allOfFeature"] == "Boss-Extrude3", s(&st[7]));
// A face point that is on no face is refused, by step.
let r = b.call("swx_run_script", json!({"targetDocument": r["documentName"], "script": [
{"op": "sketch_circle", "face": {"atPointMm": [0, 3, 0]}, "radiusMm": 1},
{"op": "extrude", "depthMm": 1}
]}));
check!(b, "a face point inside the solid is no face", r["success"] == false && r["error"].as_str().unwrap_or("").contains("no face of the part passes through"), s(&r));
}
#[test]
fn the_script_help_teaches_the_new_grammar_and_the_conventions() {
let (b, _m) = boot("issue1-help");
let r = b.call("swx_run_script", json!({"script": [{"op": "fly"}]}));
let conv = r["conventions"].to_string();
check!(
b,
"a rejected script returns every op, its args, and the coordinate conventions (corner anchor, Top Plane -Z, cut along -normal)",
r["errorCode"] == "bad_script"
&& ["sketch", "fillet", "chamfer", "shell", "linear_pattern", "circular_pattern", "set_appearance"].iter().all(|o| r["opArgs"].get(*o).is_some())
&& conv.contains("CORNER") && conv.contains("−Z") && conv.contains("−NORMAL"),
s(&r)
);
}
#[test]
fn selftest_reports_every_check_and_cleans_up_after_itself() {
let (b, _m) = boot("issue1-selftest");
std::fs::write(b.scratch.join("mock-revision"), "29.5.1").unwrap();
b.call("swx_start", json!({}));
let r = b.call("swx_selftest", json!({}));
check!(
b,
"read level: version facts (29 = SOLIDWORKS 2021: supported, and tested by a community run since 0.10.10), rows, nothing failed",
r["success"] == true && r["level"] == "read" && r["solidworks"]["versionSupport"]["year"] == 2021
&& r["solidworks"]["versionSupport"]["supported"] == true && r["solidworks"]["versionSupport"]["tested"] == true
&& r["summary"]["failed"] == 0 && r["results"].as_array().map(|a| a.len() >= 4).unwrap_or(false),
s(&r)
);
let before = b.call("swx_docs", json!({}))["count"].clone();
let r = b.call("swx_selftest", json!({"level": "write"}));
let failed: Vec<Value> = r["results"].as_array().cloned().unwrap_or_default().into_iter().filter(|x| x["pass"] == false).collect();
check!(
b,
"write level: every modelling op and read-back passes in the simulator, one row each",
r["success"] == true && failed.is_empty() && r["summary"]["passed"].as_u64().unwrap_or(0) >= 20,
format!("{}\nFAILED: {}", s(&r["summary"]), s(&Value::Array(failed)))
);
let after = b.call("swx_docs", json!({}))["count"].clone();
check!(b, "the scratch part was CLOSED: the open-document count is unchanged", before == after, format!("{before} vs {after}"));
let bad = b.call("swx_selftest", json!({"level": "everything"}));
check!(b, "an unknown level is refused", bad["errorCode"] == "bad_level", s(&bad));
}
/// MEASURED 2026-10-13 (hosted 0.10.0, SOLIDWORKS closed): the self-test
/// reported swx_docs and swx_get_preferences as FAILURES ("SOLIDWORKS is not
/// running") — false failures a user would have sent back.
#[test]
fn selftest_with_solidworks_closed_skips_instead_of_failing_and_write_refuses() {
let (b, _m) = boot("issue1-selftest-closed");
let r = b.call("swx_selftest", json!({}));
let rows = r["results"].as_array().cloned().unwrap_or_default();
let skipped_why = |verb: &str| rows.iter().any(|x| x["verb"] == verb && x["pass"].is_null() && x["skipped"] == "SOLIDWORKS is not running");
check!(
b,
"read level, SOLIDWORKS closed: nothing FAILED; docs/preferences/active-document reads are SKIPPED, why said; solidworksRunning:false",
r["success"] == true && r["summary"]["failed"] == 0 && r["summary"]["solidworksRunning"] == false
&& r["summary"]["passed"] == 2 && skipped_why("swx_docs") && skipped_why("swx_get_preferences") && skipped_why("swx_design_info"),
s(&r)
);
check!(
b,
"the hint's FIRST sentence says to start SOLIDWORKS and how many checks could run",
r["_hint"].as_str().unwrap_or("").starts_with("Start SOLIDWORKS (swx_start, or by hand) and run this again — with it closed only 2 checks can run."),
s(&r["_hint"])
);
let w = b.call("swx_selftest", json!({"level": "write"}));
check!(
b,
"write level, SOLIDWORKS closed: refused UP FRONT with the same advice",
w["success"] == false && w["errorCode"] == "solidworks_not_running"
&& w["_hint"].as_str().unwrap_or("").starts_with("Start SOLIDWORKS") && w["solidworksRunning"] == false,
s(&w)
);
b.call("swx_start", json!({}));
let docs = b.call("swx_docs", json!({}));
let ledger = b.call("swx_action_ledger", json!({"limit": 200}));
check!(
b,
"...and changed nothing: no document was created",
docs["count"] == 0
&& !ledger["actions"].as_array().map(|a| a.iter().any(|e| e["action"] == "document_created")).unwrap_or(false),
format!("{}\n{}", s(&docs), s(&ledger))
);
}
/// Review #8: selection works only in SOLIDWORKS' ACTIVE document. A script
/// pinned to a part that is not active activates it first, and puts the user's
/// active document back afterwards.
#[test]
fn a_script_on_a_document_that_is_not_active_activates_it_and_puts_the_users_back() {
let (b, _m) = boot("issue1-activate");
let a = b.call("swx_new_document", json!({"type": "part"}));
let a_title = a["created"]["title"].as_str().unwrap_or("").to_string();
b.call("swx_run_script", json!({"targetDocument": a_title, "script": [
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 20, "heightMm": 20, "anchor": "center"},
{"op": "extrude", "depthMm": 10}
]}));
let other = b.call("swx_new_document", json!({"type": "part"}));
let other_title = other["created"]["title"].as_str().unwrap_or("").to_string();
check!(b, "the second part is the active one", b.call("swx_docs", json!({}))["active"]["title"] == other_title.as_str(), s(&other));
let r = b.call("swx_run_script", json!({"targetDocument": a_title, "script": [
{"op": "sketch_circle", "face": {"atPointMm": [0, 10, 0]}, "radiusMm": 3},
{"op": "extrude", "depthMm": 2},
{"op": "fillet", "radiusMm": 0.5, "edges": {"atPointsMm": [[0, 0, 10]]}}
]}));
check!(b, "the face sketch and the fillet ran on the INACTIVE part (it was activated)", r["success"] == true, s(&r));
check!(
b,
"...and the user's active document is back",
b.call("swx_docs", json!({}))["active"]["title"] == other_title.as_str(),
s(&b.call("swx_docs", json!({})))
);
}
/// 0.10.3 — THE FIRST LIVE RUN (SOLIDWORKS 2026): every selection after a
/// geometric pick selected NOTHING (MultiSelect2 with a VARIANT array). Now a
/// LADDER, each rung believed only when the selection count grows, the rung
/// used reported as `selectedVia`. The simulator's install is the measured one.
#[test]
fn selections_after_a_pick_climb_the_ladder_and_say_which_rung_worked() {
let (b, _m) = boot("issue1-ladder");
let script = json!([
{"op": "new_part"},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 20, "heightMm": 20, "anchor": "center"},
{"op": "extrude", "depthMm": 10},
{"op": "sketch_circle", "face": {"atPointMm": [0, 10, 0]}, "radiusMm": 3},
{"op": "extrude", "depthMm": 2},
{"op": "fillet", "radiusMm": 0.5, "edges": {"allOfFeature": "Boss-Extrude1"}},
{"op": "set_appearance", "rgb": [0, 0, 255], "target": {"faceAtPointMm": [0, 5, 10]}},
{"op": "shell", "thicknessMm": 1, "removeFacesAtPointsMm": [[5, 0, 5]]}
]);
let r = b.call("swx_run_script", json!({"script": script}));
check!(b, "the measured install (VARIANT array dead): the script runs", r["success"] == true, s(&r));
let st = r["steps"].as_array().cloned().unwrap_or_default();
let typed = json!("MultiSelect2(typed array)");
check!(
b,
"face sketch, fillet edges, face colour and shell faces each report the rung: the typed array",
st[3]["result"]["resolvedPlane"]["selectedVia"] == typed && st[5]["result"]["edges"]["selectedVia"] == typed
&& st[6]["result"]["selectedVia"] == typed && st[7]["result"]["selectedVia"] == typed,
s(&r)
);
// The typed array dead too: IEntity::Select4 per entity.
std::fs::write(b.scratch.join("mock-select-dead-typed"), "").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
let st = r["steps"].as_array().cloned().unwrap_or_default();
check!(
b,
"typed array dead: every selection falls through to IEntity.Select4, verified, and says so",
r["success"] == true && st[5]["result"]["edges"]["selectedVia"] == "IEntity.Select4"
&& st[3]["result"]["resolvedPlane"]["selectedVia"] == "IEntity.Select4",
s(&r)
);
// ...and Select4 dead: the explicit ray.
std::fs::write(b.scratch.join("mock-select-dead-select4"), "").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
let st = r["steps"].as_array().cloned().unwrap_or_default();
check!(
b,
"Select4 dead: SelectByRay, view-independent",
r["success"] == true && st[7]["result"]["selectedVia"] == "SelectByRay" && st[7]["result"]["viewDependent"] == false,
s(&r)
);
// ...and the ray dead: the view-dependent last resort, FLAGGED.
std::fs::write(b.scratch.join("mock-select-dead-ray"), "").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
let st = r["steps"].as_array().cloned().unwrap_or_default();
check!(
b,
"only SelectByID2 left: used, and the result says it went through the view",
r["success"] == true && st[5]["result"]["edges"]["viewDependent"] == true
&& st[5]["result"]["edges"]["selectedVia"].as_str().unwrap_or("").contains("view-dependent"),
s(&r)
);
// Nothing selects: the 0.10.2 live failure, as an honest error.
std::fs::write(b.scratch.join("mock-select-dead-byid"), "").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
check!(
b,
"nothing selects: step 4 fails saying the picked face could not be selected — never a silent success",
r["success"] == false && r["error"].as_str().unwrap_or("").contains("step 4 (sketch_circle) failed: the picked face could not be selected"),
s(&r)
);
}
/// 0.10.4 — PROVEN LIVE. tools/dsl-live-check.py ran 30/30 on SOLIDWORKS 2026
/// (docs/LIVE-RESULTS.md). A step now says `proven: {live, measuredOn}` from
/// ONE table (compat::OP_FACTS) — live only for a variant measured on the
/// release it ran on; swx_describe and swx_selftest report the same table.
#[test]
fn steps_say_what_was_measured_live_on_this_release() {
let (b, _m) = boot("issue1-proven");
let script = json!([
{"op": "new_part"},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 20, "heightMm": 20, "anchor": "center"},
{"op": "extrude", "depthMm": 10},
{"op": "sketch_circle", "face": {"atPointMm": [0, 10, 0]}, "radiusMm": 3},
{"op": "extrude", "depthMm": 2},
{"op": "shell", "thicknessMm": 1, "removeFacesAtPointsMm": [[5, 0, 5]]},
{"op": "sketch_rect", "plane": {"offsetFrom": "Front Plane", "offsetMm": -15}, "widthMm": 4, "heightMm": 4, "anchor": "center", "yMm": 5},
{"op": "extrude", "depthMm": 3},
{"op": "sketch_rect", "plane": "Top Plane", "widthMm": 4, "heightMm": 4, "anchor": "center", "xMm": 30},
{"op": "extrude", "depthMm": 3, "reverse": true}
]);
// The simulated install is SOLIDWORKS 2026, the release that was measured.
std::fs::write(b.scratch.join("mock-revision"), "34.3.0").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
check!(b, "the script runs", r["success"] == true, s(&r));
let st = r["steps"].as_array().cloned().unwrap_or_default();
let measured = json!([{"solidworks": 2026, "major": 34, "edition": "connected", "date": "2026-10-14", "bridge": "0.10.3", "by": "adom"},
{"solidworks": 2021, "major": 29, "edition": "desktop", "date": "2026-10-15", "bridge": "0.10.9", "by": "community"}]);
// ...and the first live CSWA run (2026-10-15, bridge 0.11.2) re-measured the
// Top Plane rect, the boss, the circle and the typed selection (the shell's
// faces are selected that way) — everything here but new_part.
let mut with_cswa = measured.clone();
with_cswa.as_array_mut().unwrap().push(json!({"solidworks": 2026, "major": 34, "edition": "connected", "date": "2026-10-15", "bridge": "0.11.2", "by": "adom"}));
check!(
b,
"measured variants are LIVE on 2026, with the measurement: new part, Top Plane rect, boss, face sketch, shell",
[0usize, 1, 2, 3, 4, 5].iter().all(|i| st[*i]["result"]["proven"]["live"] == true
&& st[*i]["result"]["proven"]["measuredOn"] == if *i == 0 { measured.clone() } else { with_cswa.clone() }),
s(&r)
);
check!(
b,
"the shell reports its route, like fillet and chamfer",
st[5]["result"]["route"] == "InsertFeatureShell",
s(&st[5])
);
check!(
b,
"a NEGATIVE offset from Front Plane was never built live: live:false, and the step names the variant",
st[6]["result"]["proven"]["live"] == false
&& st[6]["result"]["proven"]["unmeasured"][0]["variant"] == "sketch.offset.front.negative",
s(&st[6])
);
check!(
b,
"a REVERSED boss was measured by 0.10.4's checks (T33): live, with THAT measurement",
st[9]["result"]["proven"]["live"] == true
&& st[9]["result"]["proven"]["measuredOn"]
== json!([{"solidworks": 2026, "major": 34, "edition": "connected", "date": "2026-10-14", "bridge": "0.10.4", "by": "adom"}]),
s(&st[9])
);
// The same script on SOLIDWORKS 2021 (0.10.10): what Michael's community
// self-test measured is live there too; what only 0.10.4's T33+ checks
// measured (a reversed boss) is not, and says why.
std::fs::write(b.scratch.join("mock-revision"), "29.5.1").unwrap();
let r = b.call("swx_run_script", json!({"script": script}));
let st = r["steps"].as_array().cloned().unwrap_or_default();
check!(
b,
"on 2021 the community-measured steps are live (both measurements listed); the reversed boss is live:false, measured on 2026 only — and says so",
r["success"] == true
&& [0usize, 1, 2, 3, 4, 5].iter().all(|i| st[*i]["result"]["proven"]["live"] == true
&& st[*i]["result"]["proven"]["measuredOn"] == if *i == 0 { measured.clone() } else { with_cswa.clone() })
&& st[9]["result"]["proven"]["live"] == false
&& st[9]["result"]["proven"]["why"].as_str().unwrap_or("").contains("this is SOLIDWORKS 2021"),
s(&r)
);
// One table: describe and selftest report what the steps report.
let d = b.call("swx_describe", json!({}));
let t = b.call("swx_selftest", json!({"level": "read"}));
let rows = |v: &Value| v["liveMeasured"]["variants"].as_array().map(|a| a.len()).unwrap_or(0);
check!(
b,
"swx_describe and swx_selftest carry the same table; the selftest's rows say what is live on THIS install (2021: the 32 variants the community run measured)",
rows(&d) > 20 && rows(&d) == rows(&t)
&& d["liveMeasured"]["variants"][0]["variant"] == t["liveMeasured"]["variants"][0]["variant"]
&& t["liveMeasured"]["variants"].as_array().map(|a| a.iter().filter(|r| r["liveOnThisInstall"] == true).count() == 32).unwrap_or(false),
format!("{}\n{}", s(&d["liveMeasured"]), s(&t["liveMeasured"]))
);
}