test: fix PhysicsResolveCapture/PhysicsDiagnostics static-leak isolation
xUnit's default parallel execution let diagnostic-harness tests (CellarUp, DoorBug, DoorCollisionApparatus) mutate PhysicsResolveCapture.CapturePath and PhysicsDiagnostics probe flags concurrently with victim tests (MotionInterpreter, PositionManager, PlayerMovementController, DispatcherToMovement, BSPStepUp), producing a flaky 14-26 failure range. Fixes: - Add PhysicsResolveCapture.ResetForTest() + PhysicsDiagnostics.ResetForTest() as documented test-only reset APIs (never called from production paths). - Add IDisposable to CellarUpTrajectoryReplayTests with ctor/Dispose calling both ResetForTest() — prevents CapturePath from leaking between the Capture_* tests in the same class (the immediate root cause of Capture_SkipsNonPlayerCalls finding an unexpected file). - Add xunit.runner.json (maxParallelThreads=1, parallelizeTestCollections=false) to AcDream.Core.Tests — eliminates parallelism-induced probe-flag leaks across all test classes without requiring [Collection] boilerplate on every offender. After: two consecutive runs produce the identical 12-failure set. Confirmed: LiveCompare_FirstCap_FixClosesCottageFloorCap passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a06226f9a2
commit
21ee5e1035
5 changed files with 101 additions and 1 deletions
|
|
@ -148,6 +148,24 @@ public static class PhysicsResolveCapture
|
|||
public static void ResetTickCounter() =>
|
||||
Interlocked.Exchange(ref _tickCounter, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Test-only reset: close any open writer, clear <see cref="CapturePath"/>,
|
||||
/// and reset the tick counter to 0. Call from test constructors and
|
||||
/// <c>IDisposable.Dispose()</c> to prevent static state from leaking
|
||||
/// across test-class boundaries.
|
||||
///
|
||||
/// <para>
|
||||
/// This method is intentionally <c>public</c> so test projects can call it
|
||||
/// without reflection, but it must NEVER be called from production code paths.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static void ResetForTest()
|
||||
{
|
||||
Close();
|
||||
CapturePath = null;
|
||||
Interlocked.Exchange(ref _tickCounter, 0);
|
||||
}
|
||||
|
||||
private static void EnsureWriter_NoLock()
|
||||
{
|
||||
if (_writer is not null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue