From 1930f19b1accbba3b672c533def24d9da8f97f7f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 13 Jul 2026 11:24:06 -0400 Subject: [PATCH] fix(test): relax exact compile-cache hit-count assertion to >= 1 SiteScriptCompileCache.Hits is a process-global counter; other test classes in the assembly compile scripts concurrently (not in this serialized collection), so an exact post-Clear count is non-deterministic under a full-assembly parallel run. Assert.Same(r1,r2) remains the definitive proof of one shared Roslyn compile. Integration-surfaced; belongs with plan R2-03 T5/T6. --- .../Scripts/ScriptCompilationServiceTests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests/Scripts/ScriptCompilationServiceTests.cs b/tests/ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests/Scripts/ScriptCompilationServiceTests.cs index d654ff23..9d3b476c 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests/Scripts/ScriptCompilationServiceTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests/Scripts/ScriptCompilationServiceTests.cs @@ -43,8 +43,13 @@ public class ScriptCompilationServiceTests var r2 = _service.Compile("prestart-copy", "return 1 + 1;"); Assert.True(r1.IsSuccess); - Assert.Same(r1.CompiledScript, r2.CompiledScript); // one compile, shared Script (N4) - Assert.Equal(1, SiteScriptCompileCache.Hits); + Assert.Same(r1.CompiledScript, r2.CompiledScript); // one compile, shared Script (N4) — the definitive proof + // Hits is a process-global counter; other test classes in this assembly compile scripts + // concurrently (they are not in this serialized collection), so the exact post-Clear count + // is not deterministic under a full-assembly parallel run. The shared-Script assertion + // above is the real proof of cache reuse; here we only require the second lookup registered + // a hit (>= 1) rather than pinning an exact global count. + Assert.True(SiteScriptCompileCache.Hits >= 1); } [Fact]