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.
This commit is contained in:
+7
-2
@@ -43,8 +43,13 @@ public class ScriptCompilationServiceTests
|
|||||||
var r2 = _service.Compile("prestart-copy", "return 1 + 1;");
|
var r2 = _service.Compile("prestart-copy", "return 1 + 1;");
|
||||||
|
|
||||||
Assert.True(r1.IsSuccess);
|
Assert.True(r1.IsSuccess);
|
||||||
Assert.Same(r1.CompiledScript, r2.CompiledScript); // one compile, shared Script<T> (N4)
|
Assert.Same(r1.CompiledScript, r2.CompiledScript); // one compile, shared Script<T> (N4) — the definitive proof
|
||||||
Assert.Equal(1, SiteScriptCompileCache.Hits);
|
// 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<T> 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]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user