From 817c4482ebb31d380aebb1a317af5a3b9f9732ea Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 31 Oct 2026 17:31:46 -0400 Subject: [PATCH] test(engine): scale the Default time-limit test's limit from the unlimited solve DefaultUnderATimeLimitReturnsAValidPlanNoWorseThanUnlimited failed on CI (runs 41219924107 and 41224809174, Engine.Tests job): the fixed 5 s limit assumed the unlimited Default solve takes well under a second, but it takes about 4 s locally and longer on a loaded runner. A limit shorter than the normal Irregular search correctly returns an earlier, worse plan, so the assertion only holds when the limit covers that search. Use the larger of 5 s and three times the measured unlimited solve. Red: the old test fails on one CPU shared with three busy loops; the new one passes there. Full Engine.Tests: 2780 passed, 2 skipped. --- .../IrregularSearchUntilCancelledTests.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenNest.Engine.Tests/NestingEngines/IrregularSearchUntilCancelledTests.cs b/OpenNest.Engine.Tests/NestingEngines/IrregularSearchUntilCancelledTests.cs index c2850262..35f80267 100644 --- a/OpenNest.Engine.Tests/NestingEngines/IrregularSearchUntilCancelledTests.cs +++ b/OpenNest.Engine.Tests/NestingEngines/IrregularSearchUntilCancelledTests.cs @@ -213,13 +213,16 @@ public class IrregularSearchUntilCancelledTests public void DefaultUnderATimeLimitReturnsAValidPlanNoWorseThanUnlimited() { // Irregular runs last under Default and searches until the limit; its plans compete - // with the Rectangles and Circles results already reported. The limit leaves a wide - // margin over the unlimited solve (well under a second here) so a slow machine passes. + // with the Rectangles and Circles results already reported. A limit shorter than the + // normal search correctly returns an earlier, worse plan, so the limit is scaled from + // the measured unlimited solve: seconds on a loaded CI runner, not a fixed constant. var job = MixedJob(false); + var watch = System.Diagnostics.Stopwatch.StartNew(); var normal = new DefaultNestingEngine().Solve(job); + var limit = TimeSpan.FromTicks( + System.Math.Max(TimeSpan.FromSeconds(5).Ticks, 3 * watch.Elapsed.Ticks)); - var limited = new DeadlineNestingEngine(new DefaultNestingEngine(), TimeSpan.FromSeconds(5)) - .Solve(job); + var limited = new DeadlineNestingEngine(new DefaultNestingEngine(), limit).Solve(job); LayoutAssert.Valid(job, limited); Assert.False(CandidateScore.Of(job, normal, 0).IsBetterThan(CandidateScore.Of(job, limited, 0)));