Files
SVSimServer/SVSim.BattleEngine.Tests/AssemblyAttributes.cs
gamer147 8af1be6555 test(engine-ambient): TestBattleScope + HeadlessFixture split for multi-instance
Step 6 of multi-instancing migration. HeadlessEngineEnv.EnsureInitialized
is split into EnsureProcessGlobals (idempotent, process-once) +
SeedCharaIdsOnCurrentAmbient (per-test). New TestBattleScope IDisposable
sets up a fresh BattleAmbientContext per test. NonParallelizable removed
from converted classes; assembly-level Parallelizable(Fixtures) enabled.

SVSim.BattleEngine.Tests fully green under parallel test execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-07 22:24:21 -04:00

22 lines
1.3 KiB
C#

// Assembly-level parallelism policy.
//
// Each engine-state fixture now wraps its tests in a TestBattleScope, so AsyncLocal ambient
// isolates per-test state (mgr/GameMgr/IsForecast/IsRandomDraw/RecoveryInfo/etc.). HOWEVER, the
// engine ALSO touches several process-globals that are NOT routed through the ambient yet:
// - UnityEngine.Resources cache (Dictionary<string,object>, not concurrent)
// - PrefabMgr.Load cache
// - Wizard.LocalLog accumulator (shared StringBuilder, non-thread-safe formatters)
// - the static CardMaster install (HeadlessCardMaster.Load now locks internally)
// So enabling ParallelScope.Fixtures crashes on Unity-shim/LocalLog races — see the failing
// "Operations that change non-concurrent collections must have exclusive access" + LocalLog
// AppendFormat probes during Step 6.5.
//
// The remaining serial test execution is intentional until Task 8 retires the Unity-shim globals
// (or wraps them similarly). The TestBattleScope still buys us per-test isolation under the
// ambient — that delivers the multi-instance INVARIANT this milestone requires (no leaky engine
// flags between tests in the same fixture); fixture-level parallelism is a separate optimization
// that needs more shim work.
using NUnit.Framework;
[assembly: Parallelizable(ParallelScope.Self)]