Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Fix flaky dielectric_preflight_and_start test: render a view that does not hit a box edge (#7722)

bherbruck35913ced4686
diff --git a/crates/engine/src/cmd/render/job_tests.rs b/crates/engine/src/cmd/render/job_tests.rs
index 4b83916051..b534d34381 100644
--- a/crates/engine/src/cmd/render/job_tests.rs
+++ b/crates/engine/src/cmd/render/job_tests.rs
@@ -1044,9 +1044,13 @@ fn dielectric_preflight_and_start_resolve_refraction_without_broadening_boundari
let mut s = Session::default();
s.set_render_job_host(Some(host.clone())).unwrap();
s.execute("solid.box", &json!({"length":20,"width":20,"height":2,"body_name":"Glass"})).unwrap();
+ // The default view sends the single pixel's ray exactly through a box edge, which the optics reject
+ // as an ambiguous interface normal. Whether the job then ends Failed or Cancelled would depend on
+ // whether the cancel below beats the render thread, so view the glass off-axis.
+ let camera = solidcraft_render::Camera { yaw: 0.3, pitch: 0.4, ..Default::default() };
let document = s.doc.clone();
let before = (s.revision, s.evaluations, s.is_dirty(), s.undo.len(), s.redo.len());
- let params = json!({"integrator":"raytrace","settings":{"width":1,"height":1},"raytrace":{"dielectrics":[{
+ let params = json!({"integrator":"raytrace","settings":{"width":1,"height":1,"camera":camera},"raytrace":{"dielectrics":[{
"body_index":0,"body_name":"Glass","boundary":"closed_box","ior":1.5,"absorption_per_mm":[0,0,0],"thickness_mm":0
}]}});
for command in ["render.preflight", "render.start"] {
@@ -1065,7 +1069,12 @@ fn dielectric_preflight_and_start_resolve_refraction_without_broadening_boundari
let handle = s.render_job_handle(id).unwrap();
s.execute("render.cancel", &json!({"job":id})).unwrap();
let status = handle.wait_timeout(std::time::Duration::from_secs(10)).unwrap();
- assert!(matches!(status.progress.phase, solidcraft_render::job::Phase::Cancelled | solidcraft_render::job::Phase::Completed));
+ assert!(
+ matches!(status.progress.phase, solidcraft_render::job::Phase::Cancelled | solidcraft_render::job::Phase::Completed),
+ "phase {:?}, error {:?}",
+ status.progress.phase,
+ status.error
+ );
}
}
for boundary in ["closed_mesh", "thin_sheet"] {