diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a5c109905..052a0d155 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -43,7 +43,7 @@ END TEMPLATE--> ### Bugfixes -*None yet* +* `LocalizedEntityCommands` are now not initialized inside `RobustUnitTest`, fixing guaranteed test failures. ### Other diff --git a/Robust.Shared/Console/EntityConsoleHost.cs b/Robust.Shared/Console/EntityConsoleHost.cs index ede5fd364..bea23aa22 100644 --- a/Robust.Shared/Console/EntityConsoleHost.cs +++ b/Robust.Shared/Console/EntityConsoleHost.cs @@ -21,10 +21,21 @@ internal sealed class EntityConsoleHost private readonly HashSet _entityCommands = []; + /// + /// If disabled, don't automatically discover commands via reflection. + /// + /// + /// This gets disabled in certain unit tests. + /// + public bool DiscoverCommands { get; set; } = true; + public void Startup() { DebugTools.Assert(_entityCommands.Count == 0); + if (!DiscoverCommands) + return; + var deps = ((EntitySystemManager)_entitySystemManager).SystemDependencyCollection; _consoleHost.BeginRegistrationRegion(); diff --git a/Robust.UnitTesting/RobustUnitTest.cs b/Robust.UnitTesting/RobustUnitTest.cs index 6e75f666c..15df76fe6 100644 --- a/Robust.UnitTesting/RobustUnitTest.cs +++ b/Robust.UnitTesting/RobustUnitTest.cs @@ -10,6 +10,7 @@ using Robust.Server.GameStates; using Robust.Server.Physics; using Robust.Shared.ComponentTrees; using Robust.Shared.Configuration; +using Robust.Shared.Console; using Robust.Shared.Containers; using Robust.Shared.ContentPack; using Robust.Shared.GameObjects; @@ -165,6 +166,10 @@ namespace Robust.UnitTesting var entMan = deps.Resolve(); var mapMan = deps.Resolve(); + // Avoid discovering EntityCommands since they may depend on systems + // that aren't available in a unit test context. + deps.Resolve().DiscoverCommands = false; + // Required components for the engine to work // Why are we still here? Just to suffer? Why can't we just use [RegisterComponent] magic? // TODO End Suffering.