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
|
|
@ -18,6 +18,15 @@
|
|||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- T0: force serial test execution to prevent PhysicsResolveCapture /
|
||||
PhysicsDiagnostics static state from leaking between test classes.
|
||||
These statics are mutated by diagnostic-harness tests; xUnit's
|
||||
default parallel execution races them against victim tests like
|
||||
MotionInterpreterTests and PlayerMovementControllerTests. -->
|
||||
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\AcDream.Core\AcDream.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\AcDream.App\AcDream.App.csproj" />
|
||||
|
|
|
|||
|
|
@ -80,8 +80,25 @@ namespace AcDream.Core.Tests.Physics;
|
|||
/// trajectory shape.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class CellarUpTrajectoryReplayTests
|
||||
public class CellarUpTrajectoryReplayTests : IDisposable
|
||||
{
|
||||
// ── T0: constructor + Dispose reset PhysicsResolveCapture static ────────
|
||||
// xUnit creates a fresh instance per test, so the constructor runs before
|
||||
// each test and Dispose runs after. Resetting here guarantees that no
|
||||
// prior test in this class can leave CapturePath set (which would cause
|
||||
// Capture_SkipsNonPlayerCalls to find an unexpected file).
|
||||
public CellarUpTrajectoryReplayTests()
|
||||
{
|
||||
PhysicsResolveCapture.ResetForTest();
|
||||
PhysicsDiagnostics.ResetForTest();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PhysicsResolveCapture.ResetForTest();
|
||||
PhysicsDiagnostics.ResetForTest();
|
||||
}
|
||||
|
||||
// ── Cellar / cottage geometry constants ────────────────────────
|
||||
private const uint CellarId = 0xA9B40147u;
|
||||
private const uint CottageNeighborA = 0xA9B40143u;
|
||||
|
|
|
|||
6
tests/AcDream.Core.Tests/xunit.runner.json
Normal file
6
tests/AcDream.Core.Tests/xunit.runner.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
|
||||
"parallelizeAssembly": false,
|
||||
"parallelizeTestCollections": false,
|
||||
"maxParallelThreads": 1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue