diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d3531e47..1edd64fea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -527,8 +527,15 @@ jobs: if [ "$FULL" != true ]; then scope=(); for p in $PACKAGES; do scope+=(-p "$p"); done; fi # The GPU path tracer's tests run in their own job (GPU path tests): one at a time, they # took about 36 of this job's 45 minutes. + # A failed test does not fail the step by itself: the tests known to fail today + # (tests/KNOWN_FAILING_TESTS) may fail, any other fails it, and so does a listed test + # that passes. nextest's exit code 100 is "tests failed"; any other is its own error + # (a build error, a bad filter) and fails the step at once. + status=0 cargo nextest run "${scope[@]}" --cargo-profile ci --locked --profile ci --no-tests=pass \ - --ignore-default-filter -E "($base) & not (package(=solidcraft-gpu) & test(/^path::/))" + --ignore-default-filter -E "($base) & not (package(=solidcraft-gpu) & test(/^path::/))" || status=$? + if [ "$status" -ne 0 ] && [ "$status" -ne 100 ]; then exit "$status"; fi + cargo xtask known-failing --junit "$junit" - name: Compiler cache statistics if: always() run: sccache --show-stats @@ -620,8 +627,14 @@ jobs: # None of these is in the default filter (the heavy tests), so pull requests, the merge # queue, main and nightly all run every one of them, as before. `count` deals the tests # out in turn (27 each); `hash` split them 41/40/27 across three shards. + # Graded against tests/KNOWN_FAILING_TESTS, as in Native Linux tests. + junit=${CARGO_TARGET_DIR:-target}/nextest/ci/junit.xml + rm -f "$junit" + status=0 cargo nextest run -p solidcraft-gpu --cargo-profile ci --locked --profile ci --no-tests=pass \ - --ignore-default-filter -E 'test(/^path::/)' --partition "count:$SHARD/4" + --ignore-default-filter -E 'test(/^path::/)' --partition "count:$SHARD/4" || status=$? + if [ "$status" -ne 0 ] && [ "$status" -ne 100 ]; then exit "$status"; fi + cargo xtask known-failing --junit "$junit" - name: Compiler cache statistics if: always() run: sccache --show-stats diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rs index 5755dcc74..d1356628e 100644 --- a/crates/doc/src/eval.rs +++ b/crates/doc/src/eval.rs @@ -5275,37 +5275,46 @@ pub(crate) fn path_segments_at(ps: &SolvedSketch, ids: &[String], start: Vec3, p if let Some(path) = path_points(ps, ids, start)? { return Ok(path.points().windows(2).map(|w| kernel::PathSeg::Line { a: w[0], b: w[1] }).collect()); } - let mut segs: Vec = Vec::new(); + // Each curve as its exact pieces (Béziers, conics) where it has them, in its own direction + // of travel. A curve is turned round whole: its pieces stay one run. + let mut curves: Vec> = Vec::with_capacity(ids.len()); for id in ids { let ci = ps.sketch.curve_index(id).ok_or_else(|| DocError::Unknown(format!("path curve `{id}`")))?; - // A free-form curve as its exact pieces (Béziers, conics) where it has them. - segs.extend(ps.sketch.exact_segs(ci).unwrap_or_else(|| ps.sketch.segs(ci))); + curves.push(ps.sketch.exact_segs(ci).unwrap_or_else(|| ps.sketch.segs(ci))); } - // Orient the chain: the first segment starts at the end nearest `start`, each next one - // starts where the previous ended. + curves.retain(|c| !c.is_empty()); + let ends = |c: &[solidcraft_geom::Seg2]| c.first().zip(c.last()).map(|(f, l)| (f.start(), l.end())); + let reversed = |c: Vec| c.into_iter().rev().map(|s| s.reversed()).collect::>(); + // Where two curves meet: one tolerance for telling which ends touch and for the joint. + const JOINT: f64 = 1e-5; + // Orient the first curve: it runs toward the second where it meets it at one end only; + // otherwise (one curve, or a second meeting it at both ends) from the end nearest `start` + // (no start given, a pipe: as drawn). let w = |p: Vec2| ps.plane.to_world(p); - if let (Some(f), true) = (segs.first().copied(), !segs.is_empty()) - && w(f.end()).dist(start) < w(f.start()).dist(start) - && (segs.len() == 1 || segs.get(1).is_some_and(|n| n.start().dist(f.start()) < 1e-6 || n.end().dist(f.start()) < 1e-6)) - { - segs[0] = f.reversed(); - } - // No start given (a pipe): the first curve runs toward the second. - if !start.is_finite() - && let (Some(f), Some(n)) = (segs.first().copied(), segs.get(1).copied()) - && (n.start().dist(f.start()) < 1e-6 || n.end().dist(f.start()) < 1e-6) - { - segs[0] = f.reversed(); - } - for i in 1..segs.len() { - let prev_end = segs[i - 1].end(); - if segs[i].end().dist(prev_end) < segs[i].start().dist(prev_end) { - segs[i] = segs[i].reversed(); - } - if segs[i].start().dist(prev_end) > 1e-5 { - return Err(DocError::Invalid("the path curves are not connected end to end".into())); + if let Some((a, b)) = curves.first().and_then(|c| ends(c)) { + let touches = |p: Vec2| curves.get(1).and_then(|n| ends(n)).is_some_and(|(na, nb)| na.dist(p) <= JOINT || nb.dist(p) <= JOINT); + let flip = match (touches(a), touches(b)) { + (true, false) => true, + (false, true) => false, + _ => start.is_finite() && w(b).dist(start) < w(a).dist(start), + }; + if flip && let Some(first) = curves.first_mut() { + *first = reversed(std::mem::take(first)); } } + // Each next curve starts where the previous one ended. + let mut segs: Vec = Vec::new(); + for curve in curves { + let (Some(prev_end), Some((a, b))) = (segs.last().map(solidcraft_geom::Seg2::end), ends(&curve)) else { + segs.extend(curve); + continue; + }; + let curve = if b.dist(prev_end) < a.dist(prev_end) { reversed(curve) } else { curve }; + segs.extend(curve); + } + if segs.windows(2).any(|pair| pair[1].start().dist(pair[0].end()) > JOINT) { + return Err(DocError::Invalid("the path curves are not connected end to end".into())); + } if let Some(profile) = profile { segs = from_profile_on_closed_path(segs, &ps.plane, profile, start); } diff --git a/crates/engine/src/cmd/sweep_options_tests.rs b/crates/engine/src/cmd/sweep_options_tests.rs index 330dd08f7..ceeb5f95c 100644 --- a/crates/engine/src/cmd/sweep_options_tests.rs +++ b/crates/engine/src/cmd/sweep_options_tests.rs @@ -192,3 +192,25 @@ fn a_sweep_round_a_closed_path_starts_where_the_profile_is() { assert!((got - want).abs() < 0.08, "{:?}", m.bbox); } } + +/// #3604: a path whose first curve is a spline of several exact pieces, the next curve meeting +/// it at its start, follows the spline back from its end: a curve is turned round whole, not +/// piece by piece. A 2 x 2 profile at the spline's end (20, 0), swept along the spline through +/// (20, 0), (10, 0), (0, 0) and on along the line to (-15, 0): a 35 long bar. +#[test] +fn a_path_turns_a_spline_of_several_pieces_round_whole() { + let mut s = Session::default(); + run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Path"})); + run(&mut s, "sketch.spline.fit_point", json!({"points": [[0, 0], [10, 0], [20, 0]], "ids": ["s1"]})); + run(&mut s, "sketch.line", json!({"points": [[-15, 0], [0, 0]], "infer": false, "ids": ["l1"]})); + run(&mut s, "sketch.finish", json!({})); + run(&mut s, "sketch.create", json!({"plane": {"origin": [20, 0, 0], "x_dir": [0, 1, 0], "y_dir": [0, 0, 1]}, "name": "Prof"})); + run(&mut s, "sketch.rectangle.center", json!({"center": [0, 0], "corner": [1, 1]})); + run(&mut s, "sketch.finish", json!({})); + run(&mut s, "solid.sweep", json!({"sketch": "Prof", "path_sketch": "Path", "path": ["s1", "l1"], "operation": "new", "body_name": "Bar"})); + let m = measure(&s, "Bar"); + assert!((m.volume - 140.0).abs() < 140.0 * 1e-6, "{}", m.volume); + for (got, want) in [(m.bbox.min.x, -15.0), (m.bbox.max.x, 20.0), (m.bbox.min.y, -1.0), (m.bbox.max.y, 1.0)] { + assert!((got - want).abs() < 0.04, "{:?}", m.bbox); + } +} diff --git a/skills/solidcraft-tests/SKILL.md b/skills/solidcraft-tests/SKILL.md index 424440e1c..9a5a04e8e 100644 --- a/skills/solidcraft-tests/SKILL.md +++ b/skills/solidcraft-tests/SKILL.md @@ -19,7 +19,7 @@ The long form is `docs/book/src/dev/testing.md`. - The rig (`tests/kernel-cases/`) asserts geometry: exact volumes, shapes, seam continuity, geometric refusals, through commands with a hand-derived answer, so it survives a kernel swap (`fillets/190-fillet-disc-rim-past-its-2mm-wall`). A test doing both keeps only its logic. ## A failing test needs its fix -A failing test cannot merge without its fix (it turns `main` red): include the fix, or mark the test `#[ignore = "fails until #123 is fixed"]` and remove that line in the PR that fixes it. +A failing test cannot merge without its fix (it turns `main` red): include it, or list the test and cause in `tests/KNOWN_FAILING_TESTS` (`cargo xtask known-failing`); the fix drops the line. ## Running - `cargo xtask test` builds with the `ci` profile and runs every test binary at once; arguments after `--` go to each binary (`cargo xtask test -- shell`). It builds several times faster than `--release`; a test failing only in a debug build: say so in the PR. diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index 2aaf3e407..d906f9091 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -7,4 +7,14 @@ # directory each (`gh run download -R tangency-labs/solidcraft -n -D /` # for junit and junit-gpu-1..4), run `cargo xtask known-failing --junit `, then drop each # FIXED line and add each REGRESSION line with its cause, from the test's failure message. -# Baseline: none yet. +# Baseline: develop 38fd4a4f6 (CI run 41157648345, x86_64 Linux), after the SMLib eaa998a pin. +solidcraft-cli::action_matrix::action_matrix_sample 7 baseline actions fail on SMLib: 4 shells (status 1001 x3; Bad Loop Orient on issue-616-lid-ribs), 2 chamfers (status 1001 on up-down-join; not a closed solid on modern-plastic), 1 fillet (SmSurfOfRevolution Test #7 on oblique_cut_of_cylinder) +solidcraft-cli::naming_corpus::corpus_designs_name_alike_every_build_and_fail_where_a_reference_is_gone oracle/83-boundary-loop-thicken does not load: step 8, SMLib thicken status 1001 +solidcraft-engine::tests::fillet_fit_taper_closes_to_a_point SMLib fillet status 1001 on the taper fit (radius 16 closing to 0) +solidcraft-engine::tests::robustness::shell_after_a_cut_whose_end_touches_an_arc_side SMLib shell status 1001 (a heavy test: pushes and nightly only) +solidcraft-kernel::blend::corner_tests::a_round_ending_in_an_earlier_round_matches_both_together SMLib fillet status 1001 on the round that ends in the earlier one +solidcraft-kernel::blend::corner_tests::corner_blends_hold_at_any_scale at 0.01x the arc case's rounds remove 72.783 (scaled back) against 72.713 at 1x (9.6e-4 off, 1e-4 allowed) +solidcraft-kernel::blend_corner::tests::issue2422_vertical_after_separate_bottom_rounds SMLib's check refuses the fillet: edge and vertex tolerance 0.97 against the body's 0.01 (#2422) +solidcraft-kernel::corner_g2::tests::a_long_setback_keeps_the_g2_patch_inside_the_box at set backs 11 to 15 the G2 corner patch bulges 2.6e-6 to 1.33e-3 past the box (the explicit corner is in progress) +solidcraft-kernel::corner_g2::tests::the_box_corner_g2_patch_is_a_closed_solid_curvature_continuous_to_its_neighbours the fitted G2 corner patch bulges 1.7e-5 past the box, which SMLib's exact tight box now sees (the explicit G2 corner builds it inside) +solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the arc and tab rounds together remove 9.20067 against 9.20420 (3.8e-4 off, 1e-5 allowed) diff --git a/tests/oracle/34-chamfer-then-fillet/expected.json b/tests/oracle/34-chamfer-then-fillet/expected.json index 7ed149fc4..22139c647 100644 --- a/tests/oracle/34-chamfer-then-fillet/expected.json +++ b/tests/oracle/34-chamfer-then-fillet/expected.json @@ -1,5 +1,6 @@ { "source": "freecad 1.1.4", + "known_failure": "SMLib fillet: STEP export finds edges 4.6e-5 to 6.1e-5 off their surfaces against 2e-5", "method": "FreeCAD (OpenCASCADE) build of recipe.json by tools/freecad-oracle/build.py: Part extrude, Part makeChamfer, Part makeFillet", "body_count": 1, "volume_mm3": 22892.42132988775, diff --git a/tests/oracle/35-fillet-curved-curved/expected.json b/tests/oracle/35-fillet-curved-curved/expected.json index 39dddae7e..feba69fe3 100644 --- a/tests/oracle/35-fillet-curved-curved/expected.json +++ b/tests/oracle/35-fillet-curved-curved/expected.json @@ -1,5 +1,6 @@ { "source": "freecad 1.1.4", + "known_failure": "SMLib fillet: STEP export finds edges 4.6e-5 to 6.1e-5 off their surfaces against 2e-5", "method": "FreeCAD (OpenCASCADE) build of recipe.json by tools/freecad-oracle/build.py: Part extrude, Part extrude join, Part makeFillet", "body_count": 1, "volume_mm3": 63171.61517720092, diff --git a/tests/oracle/37-pyramid-apex-blend/expected.json b/tests/oracle/37-pyramid-apex-blend/expected.json index faf45e1f5..6edd3e21f 100644 --- a/tests/oracle/37-pyramid-apex-blend/expected.json +++ b/tests/oracle/37-pyramid-apex-blend/expected.json @@ -1,5 +1,6 @@ { "source": "freecad 1.1.4", + "known_failure": "the apex blend's shape is 0.193 mm off the reference (at most 0.05)", "method": "FreeCAD (OpenCASCADE) build of recipe.json by tools/freecad-oracle/build.py: Part.makeLoft, Part makeFillet", "body_count": 1, "volume_mm3": 15465.577113384288, diff --git a/tests/oracle/77-fillet-variable-linear/expected.json b/tests/oracle/77-fillet-variable-linear/expected.json index 97615472e..33ad077c0 100644 --- a/tests/oracle/77-fillet-variable-linear/expected.json +++ b/tests/oracle/77-fillet-variable-linear/expected.json @@ -1,5 +1,6 @@ { "source": "analytic", + "known_failure": "SMLib variable fillet: STEP export finds edges 4.6e-5 to 6.1e-5 off their surfaces against 2e-5", "method": "box 40x30x20 with its top front edge (y=0, z=20) rounded at a radius running straight from 2 (x=0) to 5 (x=40): sections are quarter rounds, V = abc - (1 - pi/4) L (a^2 + ab + b^2) / 3; moments and the round's area integrated along the edge (tools/oracle-analytic/cases_fillets.py)", "body_count": 1, "volume_mm3": 23888.407044966672, diff --git a/tests/oracle/78-fillet-variable-to-zero/expected.json b/tests/oracle/78-fillet-variable-to-zero/expected.json index fa6bf793a..8d11c9c49 100644 --- a/tests/oracle/78-fillet-variable-to-zero/expected.json +++ b/tests/oracle/78-fillet-variable-to-zero/expected.json @@ -1,5 +1,6 @@ { "source": "analytic", + "known_failure": "SMLib variable fillet: STEP export finds edges 4.6e-5 to 6.1e-5 off their surfaces against 2e-5", "method": "as 77 with the radius running from 4 (x=0) down to 0 (x=40), where the round closes to the corner: V = abc - (1 - pi/4) L a^2 / 3; the round is three-sided and the corner at x=40 stays", "body_count": 1, "volume_mm3": 23954.21827485812, diff --git a/tests/oracle/80-fillet-taper-to-fit/expected.json b/tests/oracle/80-fillet-taper-to-fit/expected.json index 30850ccb0..255552af7 100644 --- a/tests/oracle/80-fillet-taper-to-fit/expected.json +++ b/tests/oracle/80-fillet-taper-to-fit/expected.json @@ -1,5 +1,6 @@ { "source": "analytic", + "known_failure": "the taper-to-fit round's area is off the reference (the fillet room law)", "method": "plate (top 20 -> 2 wide over x 0..40, 15 high) with its top front edge filleted at 3, fit: taper. The radius is the taper law: a clamped cubic B-spline in u = x/40 on 8 equal spans, control radii min(3, 0.9 room) at the Greville abscissae, room = min(20 - 18u, 15) tan 45 deg (top face width, front face height): 3.0000, 3.0000, 3.0000, 3.0000, 3.0000, 3.0000, 3.0000, 3.0000, 3.0000, 2.4750, 1.8000. Sections are quarter rounds; V, moments and areas integrated along the edge", "body_count": 1, "volume_mm3": 6525.960225143974, diff --git a/tests/oracle/81-fillet-spline-radius/expected.json b/tests/oracle/81-fillet-spline-radius/expected.json index 392a2b5f7..66993e418 100644 --- a/tests/oracle/81-fillet-spline-radius/expected.json +++ b/tests/oracle/81-fillet-spline-radius/expected.json @@ -1,5 +1,6 @@ { "source": "analytic", + "known_failure": "SMLib variable fillet: STEP export finds edges 4.6e-5 to 6.1e-5 off their surfaces against 2e-5", "method": "box 40x30x20 with its top front edge (y=0, z=20) rounded at a radius that is a clamped cubic B-spline in u = x/40, knots 0,0,0,0,0.25,0.6,1,1,1,1, control radii 2, 5, 1.5, 4, 1, 3 (r(0) = 2, r(40) = 3). Sections are quarter rounds; V, moments and areas integrated along the edge, exactly per knot span", "body_count": 1, "volume_mm3": 23933.601078437176, diff --git a/tests/oracle/83-boundary-loop-thicken/expected.json b/tests/oracle/83-boundary-loop-thicken/expected.json index a2b050e30..8deaae025 100644 --- a/tests/oracle/83-boundary-loop-thicken/expected.json +++ b/tests/oracle/83-boundary-loop-thicken/expected.json @@ -1,5 +1,6 @@ { "source": "analytic", + "known_failure": "SMLib thicken fails (status 1001)", "method": "region = 10 x 10 square + half disc r 5 on its top side: A = 100 + 12.5 pi, centroid by moments (half disc's at 4r / (3 pi) above its diameter); slab of thickness 2 over it (symmetric about z = 0): V = 2A, area = 2A + 2 (30 + 5 pi)", "body_count": 1, "volume_mm3": 278.53981633974485,