mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Make RobustIntegrationTest pool by default (#5872)
This commit is contained in:
@@ -35,7 +35,9 @@ END TEMPLATE-->
|
||||
|
||||
### Breaking changes
|
||||
|
||||
*None yet*
|
||||
* `RobustIntegrationTest` now pools server/client instances by default. If a custom settings class is provided, it will still disable pooling unless explicitly enabled.
|
||||
* Server/Client instances that are returned to the pool should be disconnected. This might require you to update some tests.
|
||||
* Pooled instances also require you to use `RobustIntegrationTest` methods like `WaitPost()` to ensure the correct thread is used.
|
||||
|
||||
### New features
|
||||
|
||||
@@ -43,7 +45,7 @@ END TEMPLATE-->
|
||||
|
||||
### Bugfixes
|
||||
|
||||
*None yet*
|
||||
* Fix `EntityDeserializer` improperly setting entity lifestages when loading a post-mapinit map.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ public class RecursiveMoveBenchmark : RobustIntegrationTest
|
||||
public void GlobalSetup()
|
||||
{
|
||||
ProgramShared.PathOffset = "../../../../";
|
||||
var server = StartServer();
|
||||
var client = StartClient();
|
||||
var server = StartServer(new() {Pool = false});
|
||||
var client = StartClient(new() {Pool = false});
|
||||
|
||||
Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()).Wait();
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ internal struct PvsMetadata
|
||||
{
|
||||
DebugTools.AssertEqual(NetEntity, comp.NetEntity);
|
||||
DebugTools.AssertEqual(VisMask, comp.VisibilityMask);
|
||||
DebugTools.Assert(LifeStage == comp.EntityLifeStage);
|
||||
DebugTools.AssertEqual(LifeStage, comp.EntityLifeStage);
|
||||
DebugTools.Assert(LastModifiedTick == comp.EntityLastModifiedTick || LastModifiedTick.Value == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,7 +1000,7 @@ public sealed class EntityDeserializer :
|
||||
continue;
|
||||
|
||||
DebugTools.Assert(meta.EntityLifeStage == EntityLifeStage.Initialized);
|
||||
meta.EntityLifeStage = EntityLifeStage.MapInitialized;
|
||||
EntMan.SetLifeStage(meta, EntityLifeStage.MapInitialized);
|
||||
}
|
||||
|
||||
_log.Debug($"Finished flagging mapinit in {_stopwatch.Elapsed}");
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// The current lifetime stage of this entity. You can use this to check
|
||||
/// if the entity is initialized or being deleted.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[ViewVariables, Access(typeof(EntityManager), Other = AccessPermissions.ReadExecute)]
|
||||
public EntityLifeStage EntityLifeStage { get; internal set; }
|
||||
|
||||
public MetaDataFlags Flags
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.UnitTesting.Client.GameObjects.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that content can correctly override an occluder's directions instead of relying on the default anchoring behaviour.
|
||||
/// The directions are used for connecting occluders together.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public sealed class OccluderDirectionsTest : RobustIntegrationTest
|
||||
{
|
||||
/* See https://github.com/space-wizards/RobustToolbox/pull/2528 for why this is commented out as the technology isn't there yet.
|
||||
[Test]
|
||||
public async Task TestOccluderOverride()
|
||||
{
|
||||
var client = StartClient();
|
||||
|
||||
await client.WaitIdleAsync();
|
||||
|
||||
var entManager = client.ResolveDependency<IEntityManager>();
|
||||
var mapManager = client.ResolveDependency<IMapManager>();
|
||||
|
||||
var overrider = new OccluderOverrider();
|
||||
entManager.EventBus.SubscribeEvent<OccluderDirectionsEvent>(EventSource.Local, overrider, EventHandler);
|
||||
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
var occ = entManager.SpawnEntity(null, new MapCoordinates(Vector2.Zero, mapId));
|
||||
var occluder = entManager.AddComponent<ClientOccluderComponent>(occ);
|
||||
|
||||
Assert.That(occluder.Occluding, Is.EqualTo(OccluderDir.None));
|
||||
occluder.Update();
|
||||
Assert.That(occluder.Occluding, Is.EqualTo(OccluderDir.East));
|
||||
});
|
||||
}
|
||||
|
||||
private static void EventHandler(ref OccluderDirectionsEvent ev)
|
||||
{
|
||||
ev.Handled = true;
|
||||
ev.Directions = OccluderDir.East;
|
||||
}
|
||||
|
||||
private sealed class OccluderOverrider : IEntityEventSubscriber {}
|
||||
*/
|
||||
}
|
||||
@@ -33,6 +33,7 @@ using Robust.Shared.Input;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -171,7 +172,19 @@ namespace Robust.UnitTesting
|
||||
|
||||
private bool ShouldPool(IntegrationOptions? options)
|
||||
{
|
||||
return options?.Pool ?? false;
|
||||
// If no options are provided, we assume we should pool
|
||||
if (options == null)
|
||||
return true;
|
||||
|
||||
// If custom options are provided without explicitly setting pool=true, we assume we shouldn't pool.
|
||||
if (options is not {Pool: true})
|
||||
return false;
|
||||
|
||||
if (!options.Asynchronous)
|
||||
throw new Exception("Invalid options. Pooled instances must be asynchronous");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected virtual async Task OnInstanceReturn(IntegrationInstance instance)
|
||||
@@ -203,28 +216,14 @@ namespace Robust.UnitTesting
|
||||
{
|
||||
foreach (var client in _clientsRunning.Keys)
|
||||
{
|
||||
await client.WaitIdleAsync();
|
||||
|
||||
if (client.UnhandledException != null || !client.IsAlive)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ClientsReady.Enqueue(client);
|
||||
await ReturnToPool(client);
|
||||
}
|
||||
|
||||
_clientsRunning.Clear();
|
||||
|
||||
foreach (var server in _serversRunning.Keys)
|
||||
{
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
if (server.UnhandledException != null || !server.IsAlive)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ServersReady.Enqueue(server);
|
||||
await ReturnToPool(server);
|
||||
}
|
||||
|
||||
_serversRunning.Clear();
|
||||
@@ -234,6 +233,43 @@ namespace Robust.UnitTesting
|
||||
_notPooledInstances.Clear();
|
||||
}
|
||||
|
||||
public async Task ReturnToPool(ClientIntegrationInstance client)
|
||||
{
|
||||
if (!_clientsRunning.Remove(client, out _))
|
||||
return;
|
||||
|
||||
var res = await ReturnToPoolInternal(client);
|
||||
if (res)
|
||||
ClientsReady.Enqueue(client);
|
||||
}
|
||||
|
||||
public async Task ReturnToPool(ServerIntegrationInstance server)
|
||||
{
|
||||
if (!_serversRunning.Remove(server, out _))
|
||||
return;
|
||||
|
||||
var res = await ReturnToPoolInternal(server);
|
||||
if (res)
|
||||
ServersReady.Enqueue(server);
|
||||
}
|
||||
|
||||
public async Task<bool> ReturnToPoolInternal(IntegrationInstance instance)
|
||||
{
|
||||
await instance.WaitIdleAsync();
|
||||
if (instance.UnhandledException != null || !instance.IsAlive)
|
||||
return false;
|
||||
|
||||
var netMan = instance.ResolveDependency<INetManager>();
|
||||
Assert.That(netMan.IsConnected, Is.False);
|
||||
|
||||
// TODO Validate cvars and whatnot
|
||||
// Or just move content's PoolManager & TestPair over to engine.
|
||||
|
||||
await instance.WaitPost(() => instance.EntMan.FlushEntities());
|
||||
await instance.WaitIdleAsync();
|
||||
return instance.UnhandledException == null && instance.IsAlive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides control over a running instance of the client or server.
|
||||
/// </summary>
|
||||
@@ -414,7 +450,7 @@ namespace Robust.UnitTesting
|
||||
/// </exception>
|
||||
public Task WaitIdleAsync(bool throwOnUnhandled = true, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (Options?.Asynchronous == true)
|
||||
if (Options?.Asynchronous != false)
|
||||
{
|
||||
return WaitIdleImplAsync(throwOnUnhandled, cancellationToken);
|
||||
}
|
||||
@@ -624,7 +660,7 @@ namespace Robust.UnitTesting
|
||||
{
|
||||
ServerOptions = options;
|
||||
DependencyCollection = new DependencyCollection();
|
||||
if (options?.Asynchronous == true)
|
||||
if (options?.Asynchronous != false)
|
||||
{
|
||||
InstanceThread = new Thread(_serverMain)
|
||||
{
|
||||
@@ -839,7 +875,7 @@ namespace Robust.UnitTesting
|
||||
ClientOptions = options;
|
||||
DependencyCollection = new DependencyCollection();
|
||||
|
||||
if (options?.Asynchronous == true)
|
||||
if (options?.Asynchronous != false)
|
||||
{
|
||||
InstanceThread = new Thread(ThreadMain)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@ public sealed class DefaultEntityTest : RobustIntegrationTest
|
||||
var netMan = client.ResolveDependency<IClientNetManager>();
|
||||
var playerMan = server.ResolveDependency<IPlayerManager>();
|
||||
var confMan = server.ResolveDependency<IConfigurationManager>();
|
||||
var mapMan = server.ResolveDependency<IMapManager>();
|
||||
|
||||
client.SetConnectTarget(server);
|
||||
client.Post(() => netMan.ClientConnect(null!, 0, null!));
|
||||
@@ -104,6 +103,10 @@ public sealed class DefaultEntityTest : RobustIntegrationTest
|
||||
|
||||
Assert.That(sEntMan.EntityExists(sEntMan.GetEntity(ent)));
|
||||
Assert.That(cEntMan.EntityExists(cEntMan.GetEntity(ent)));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ public sealed class DetachedParentTest : RobustIntegrationTest
|
||||
[Test]
|
||||
public async Task TestDetachedParent()
|
||||
{
|
||||
var server = StartServer();
|
||||
var client = StartClient();
|
||||
var server = StartServer(new() {Pool = false});
|
||||
var client = StartClient(new() {Pool = false});
|
||||
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
@@ -441,6 +441,10 @@ public sealed class DetachedParentTest : RobustIntegrationTest
|
||||
Assert.That(cParent3X.MapUid, Is.EqualTo(cMap3));
|
||||
Assert.That(cParent4X.MapUid, Is.EqualTo(cMap3));
|
||||
Assert.That(cGrid3X.MapUid, Is.EqualTo(cMap3));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,10 @@ public sealed class MissingParentTest : RobustIntegrationTest
|
||||
Assert.That(client.Transform(entity).ParentUid.IsValid(), Is.True);
|
||||
Assert.That(client.Transform(entity).ParentUid, Is.EqualTo(newParent));
|
||||
Assert.That(client.MetaData(entity).Flags & MetaDataFlags.Detached, Is.EqualTo(MetaDataFlags.None));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,10 @@ public sealed class PvsChunkTest : RobustIntegrationTest
|
||||
Assert.That(cEntMan.TryGetEntity(nMap1, out _));
|
||||
Assert.That(!cEntMan.TryGetEntity(nMap2, out _));
|
||||
Assert.That(cEntMan.TryGetEntity(nGrid, out _));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,9 @@ public sealed class PvsReEntryTest : RobustIntegrationTest
|
||||
// If the test moves the entity instead of the player, then the test doesn't actually work.
|
||||
Assert.That(meta.LastModifiedTick, Is.EqualTo(lastDirty));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -121,6 +121,10 @@ public sealed class PvsSystemTests : RobustIntegrationTest
|
||||
await server.WaitRunTicks(1);
|
||||
await client.WaitRunTicks(1);
|
||||
}
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,9 @@ namespace Robust.UnitTesting.Shared
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
// Connect client to the server...
|
||||
var netMan = client.ResolveDependency<IClientNetManager>();
|
||||
Assert.DoesNotThrow(() => client.SetConnectTarget(server));
|
||||
client.Post(() => IoCManager.Resolve<IClientNetManager>().ClientConnect(null!, 0, null!));
|
||||
client.Post(() => netMan.ClientConnect(null!, 0, null!));
|
||||
|
||||
// Run 10 synced ticks...
|
||||
for (int i = 0; i < 10; i++)
|
||||
@@ -89,6 +90,10 @@ namespace Robust.UnitTesting.Shared
|
||||
Assert.That(netManager.ServerChannel, Is.Not.Null);
|
||||
Assert.That(netManager.ServerChannel!.IsConnected, Is.True);
|
||||
});
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class AutoIncludeSerializationTest : RobustIntegrationTest
|
||||
[Test]
|
||||
public async Task TestAutoIncludeSerialization()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new() {Pool = false}); // Pool=false due to TileDef registration
|
||||
await server.WaitIdleAsync();
|
||||
var entMan = server.EntMan;
|
||||
var mapSys = server.System<SharedMapSystem>();
|
||||
@@ -274,6 +274,7 @@ public sealed partial class AutoIncludeSerializationTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => entMan.DeleteEntity(otherMap));
|
||||
await server.WaitPost(() => entMan.DeleteEntity(grid.Comp1.ParentUid));
|
||||
await server.WaitPost(() => entMan.DeleteEntity(nullSpace));
|
||||
await server.WaitPost(() => mapSys.DeleteMap(mapId));
|
||||
AssertCount(0);
|
||||
|
||||
// Check the map file
|
||||
@@ -302,5 +303,8 @@ public sealed partial class AutoIncludeSerializationTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => entMan.DeleteEntity(otherMap));
|
||||
await server.WaitPost(() => entMan.DeleteEntity(nullSpace));
|
||||
AssertCount(0);
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.EntitySerialization.Components;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.UnitTesting.Shared.EntitySerialization.EntitySaveTestComponent;
|
||||
|
||||
@@ -51,7 +52,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
await server.WaitPost(() => mapUid = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
@@ -77,7 +78,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
var mapPath = new ResPath($"{nameof(MapDataV3Map)}.yml");
|
||||
resourceManager.MountString(mapPath.ToString(), MapDataV3Map);
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -111,7 +112,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
resourceManager.MountString(mapPath2.ToString(), MapDataV3Map);
|
||||
|
||||
var opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -137,6 +138,8 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
await server.WaitPost(() => entMan.DeleteEntity(map));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
private const string MapDataV3Grid = @"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.EntitySerialization.Components;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.UnitTesting.Shared.EntitySerialization.EntitySaveTestComponent;
|
||||
|
||||
@@ -47,7 +48,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
await server.WaitPost(() => mapUid = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
@@ -73,7 +74,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
var mapPath = new ResPath($"{nameof(MapDataV4Map)}.yml");
|
||||
resourceManager.MountString(mapPath.ToString(), MapDataV4Map);
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -107,7 +108,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
resourceManager.MountString(mapPath2.ToString(), MapDataV4Map);
|
||||
|
||||
var opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -133,6 +134,8 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
await server.WaitPost(() => entMan.DeleteEntity(map));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
private const string MapDataV4Grid = @"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.EntitySerialization.Components;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.UnitTesting.Shared.EntitySerialization.EntitySaveTestComponent;
|
||||
|
||||
@@ -47,7 +48,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
await server.WaitPost(() => mapUid = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
@@ -73,7 +74,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
var mapPath = new ResPath($"{nameof(MapDataV5Map)}.yml");
|
||||
resourceManager.MountString(mapPath.ToString(), MapDataV5Map);
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -107,7 +108,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
resourceManager.MountString(mapPath2.ToString(), MapDataV5Map);
|
||||
|
||||
var opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -133,6 +134,8 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
await server.WaitPost(() => entMan.DeleteEntity(map));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
private const string MapDataV5Grid = @"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.EntitySerialization.Components;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.UnitTesting.Shared.EntitySerialization.EntitySaveTestComponent;
|
||||
|
||||
@@ -47,7 +48,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
await server.WaitPost(() => mapUid = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
@@ -73,7 +74,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
var mapPath = new ResPath($"{nameof(MapDataV6Map)}.yml");
|
||||
resourceManager.MountString(mapPath.ToString(), MapDataV6Map);
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath, out _, out _)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -107,7 +108,7 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
resourceManager.MountString(mapPath2.ToString(), MapDataV6Map);
|
||||
|
||||
var opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(mapPath2, out _, out _, opts)));
|
||||
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(1));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -133,6 +134,8 @@ public sealed partial class BackwardsCompatibilityTest
|
||||
|
||||
await server.WaitPost(() => entMan.DeleteEntity(map));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
private const string MapDataV6Grid = @"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.EntitySerialization.Components;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.UnitTesting.Shared.EntitySerialization.EntitySaveTestComponent;
|
||||
|
||||
@@ -41,8 +42,8 @@ public sealed partial class BackwardsCompatibilityTest : RobustIntegrationTest
|
||||
tileMan.Register(new TileDef("a"));
|
||||
|
||||
void AssertCount(int expected) => Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(expected));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
|
||||
await server.WaitPost(() => mapSys.CreateMap(out _));
|
||||
var mapLoadOpts = MapLoadOptions.Default with
|
||||
{
|
||||
DeserializationOptions = DeserializationOptions.Default with {LogOrphanedGrids = false}
|
||||
@@ -85,6 +86,7 @@ public sealed partial class BackwardsCompatibilityTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => entMan.DeleteEntity(grid.Comp1.ParentUid));
|
||||
await server.WaitPost(() => entMan.DeleteEntity(nullSpace));
|
||||
AssertCount(0);
|
||||
await server.WaitPost(() => loader.Delete(result));
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +106,7 @@ public sealed partial class BackwardsCompatibilityTest : RobustIntegrationTest
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
LoadResult? result = default;
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGeneric(pathLifestage, out result)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGeneric(pathLifestage, out result)));
|
||||
Assert.That(result!.Version, Is.EqualTo(7));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(8));
|
||||
|
||||
@@ -140,7 +142,13 @@ public sealed partial class BackwardsCompatibilityTest : RobustIntegrationTest
|
||||
: Is.EqualTo(EntityLifeStage.MapInitialized));
|
||||
}
|
||||
}
|
||||
|
||||
await server.WaitPost(() => loader.Delete(result));
|
||||
}
|
||||
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<LoadedMapComponent>(), Is.EqualTo(0));
|
||||
Assert.That(entMan.Count<MapComponent>(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
private const string MapDataV7 = @"
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class CategorizationTest : RobustIntegrationTest
|
||||
[TestOf(typeof(FileCategory))]
|
||||
public async Task TestCategorization()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new() {Pool = false}); // Pool=false due to TileDef registration
|
||||
await server.WaitIdleAsync();
|
||||
var entMan = server.EntMan;
|
||||
var meta = server.System<MetaDataSystem>();
|
||||
@@ -76,7 +76,7 @@ public sealed partial class CategorizationTest : RobustIntegrationTest
|
||||
DeserializationOptions = DeserializationOptions.Default with { LogOrphanedGrids = false}
|
||||
};
|
||||
LoadResult? result = null;
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGeneric(path, out result, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGeneric(path, out result, opts)));
|
||||
Assert.That(result!.Category, Is.EqualTo(expected));
|
||||
Assert.That(result.Entities, Has.Count.EqualTo(count));
|
||||
return result;
|
||||
|
||||
@@ -87,7 +87,7 @@ public sealed partial class LifestageSerializationTest : RobustIntegrationTest
|
||||
async Task Load(ResPath f, DeserializationOptions? o)
|
||||
{
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadMap(f, out _, out _, o)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadMap(f, out _, out _, o)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(5));
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public sealed partial class LifestageSerializationTest : RobustIntegrationTest
|
||||
{
|
||||
DeserializationOptions = o ?? DeserializationOptions.Default
|
||||
};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGeneric(f, out _, oo)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGeneric(f, out _, oo)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(8));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
[Test]
|
||||
public async Task TestMapMerge()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new() {Pool = false}); // Pool=false due to TileDef registration
|
||||
await server.WaitIdleAsync();
|
||||
var entMan = server.EntMan;
|
||||
var mapSys = server.System<SharedMapSystem>();
|
||||
@@ -77,8 +77,8 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
AssertPreInit(grid);
|
||||
|
||||
// Save then delete everything
|
||||
Assert.That(loader.TrySaveMap(map, mapPath));
|
||||
Assert.That(loader.TrySaveGrid(grid, gridPath));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TrySaveMap(map, mapPath)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TrySaveGrid(grid, gridPath)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
await server.WaitPost(() => mapSys.DeleteMap(mapId));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
@@ -87,7 +87,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.CreateMap(out mapId, runMapInit: false));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.False);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
Assert.That(loader.TryLoadGrid(mapId, gridPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
grid = Find(nameof(grid), entMan);
|
||||
AssertPaused(grid);
|
||||
@@ -99,7 +99,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.CreateMap(out mapId, runMapInit: false));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.False);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
Assert.That(loader.TryMergeMap(mapId, mapPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryMergeMap(mapId, mapPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2)); // The loaded map entity gets deleted after merging
|
||||
ent = Find(nameof(ent), entMan);
|
||||
grid = Find(nameof(grid), entMan);
|
||||
@@ -114,7 +114,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.CreateMap(out mapId, runMapInit: true));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.False);
|
||||
Assert.That(loader.TryLoadGrid(mapId, gridPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
grid = Find(nameof(grid), entMan);
|
||||
AssertPaused(grid, false);
|
||||
@@ -126,7 +126,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.CreateMap(out mapId, runMapInit: true));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.False);
|
||||
Assert.That(loader.TryMergeMap(mapId, mapPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryMergeMap(mapId, mapPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
ent = Find(nameof(ent), entMan);
|
||||
grid = Find(nameof(grid), entMan);
|
||||
@@ -142,7 +142,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.SetPaused(mapId, true));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
Assert.That(loader.TryLoadGrid(mapId, gridPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
grid = Find(nameof(grid), entMan);
|
||||
AssertPaused(grid);
|
||||
@@ -155,7 +155,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
await server.WaitPost(() => mapSys.SetPaused(mapId, true));
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
Assert.That(loader.TryMergeMap(mapId, mapPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryMergeMap(mapId, mapPath, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
ent = Find(nameof(ent), entMan);
|
||||
grid = Find(nameof(grid), entMan);
|
||||
@@ -175,7 +175,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.False);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
var opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
Assert.That(loader.TryLoadGrid(mapId, gridPath, out _, opts));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _, opts)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
grid = Find(nameof(grid), entMan);
|
||||
AssertPaused(grid);
|
||||
@@ -188,7 +188,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.False);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.True);
|
||||
opts = DeserializationOptions.Default with {InitializeMaps = true};
|
||||
Assert.That(loader.TryMergeMap(mapId, mapPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryMergeMap(mapId, mapPath, out _, opts)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2)); // The loaded map entity gets deleted after merging
|
||||
ent = Find(nameof(ent), entMan);
|
||||
grid = Find(nameof(grid), entMan);
|
||||
@@ -204,7 +204,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.False);
|
||||
opts = DeserializationOptions.Default with {PauseMaps = true};
|
||||
Assert.That(loader.TryLoadGrid(mapId, gridPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, gridPath, out _, opts)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
grid = Find(nameof(grid), entMan);
|
||||
AssertPaused(grid, false);
|
||||
@@ -217,7 +217,7 @@ public sealed partial class MapMergeTest : RobustIntegrationTest
|
||||
Assert.That(mapSys.IsInitialized(mapId), Is.True);
|
||||
Assert.That(mapSys.IsPaused(mapId), Is.False);
|
||||
opts = DeserializationOptions.Default with {PauseMaps = true};
|
||||
Assert.That(loader.TryMergeMap(mapId, mapPath, out _));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryMergeMap(mapId, mapPath, out _, opts)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
ent = Find(nameof(ent), entMan);
|
||||
grid = Find(nameof(grid), entMan);
|
||||
|
||||
@@ -69,7 +69,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
|
||||
// Load in the file containing only entA.
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadEntity(pathA, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadEntity(pathA, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
entA = Find(nameof(entA), entMan);
|
||||
Assert.That(entA.Comp1!.ParentUid, Is.EqualTo(EntityUid.Invalid));
|
||||
@@ -77,7 +77,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(0));
|
||||
|
||||
// Load in the file containing entB and its child
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadEntity(pathB, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadEntity(pathB, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
entB = Find(nameof(entB), entMan);
|
||||
child = Find(nameof(child), entMan);
|
||||
@@ -92,7 +92,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
|
||||
// Load the file that contains both of them
|
||||
LoadResult? result = null;
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGeneric(pathCombined, out result)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGeneric(pathCombined, out result)));
|
||||
Assert.That(result!.Category, Is.EqualTo(FileCategory.Unknown));
|
||||
Assert.That(result.Orphans, Has.Count.EqualTo(2));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(3));
|
||||
@@ -114,7 +114,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
[Test]
|
||||
public async Task TestOrphanedGridSerialization()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new() {Pool = false}); // Pool=false due to TileDef registration
|
||||
await server.WaitIdleAsync();
|
||||
var entMan = server.EntMan;
|
||||
var mapSys = server.System<SharedMapSystem>();
|
||||
@@ -169,9 +169,10 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
Assert.That(map.Comp1!.ParentUid, Is.EqualTo(EntityUid.Invalid));
|
||||
|
||||
// Save the grids without their map
|
||||
Assert.That(loader.TrySaveGrid(gridA, pathA));
|
||||
Assert.That(loader.TrySaveGrid(gridB, pathB));
|
||||
Assert.That(loader.TrySaveGeneric([gridA.Owner, gridB.Owner], pathCombined, out var cat));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TrySaveGrid(gridA, pathA)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TrySaveGrid(gridB, pathB)));
|
||||
FileCategory cat = default;
|
||||
await server.WaitAssertion(() => Assert.That(loader.TrySaveGeneric([gridA.Owner, gridB.Owner], pathCombined, out cat)));
|
||||
Assert.That(cat, Is.EqualTo(FileCategory.Unknown));
|
||||
|
||||
// Delete all the entities.
|
||||
@@ -182,7 +183,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
// Load in the file containing only gridA.
|
||||
EntityUid newMap = default;
|
||||
await server.WaitPost(() => newMap = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, pathA, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, pathA, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(1));
|
||||
gridA = Find(nameof(gridA), entMan);
|
||||
Assert.That(gridA.Comp1.LocalPosition, Is.Approximately(new Vector2(100, 100)));
|
||||
@@ -192,7 +193,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
|
||||
// Load in the file containing gridB and its child
|
||||
await server.WaitPost(() => newMap = mapSys.CreateMap(out mapId));
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGrid(mapId, pathB, out _)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGrid(mapId, pathB, out _)));
|
||||
Assert.That(entMan.Count<EntitySaveTestComponent>(), Is.EqualTo(2));
|
||||
gridB = Find(nameof(gridB), entMan);
|
||||
child = Find(nameof(child), entMan);
|
||||
@@ -208,7 +209,7 @@ public sealed partial class OrphanSerializationTest : RobustIntegrationTest
|
||||
{
|
||||
DeserializationOptions = DeserializationOptions.Default with {LogOrphanedGrids = false}
|
||||
};
|
||||
await server.WaitPost(() => Assert.That(loader.TryLoadGeneric(pathCombined, out result, opts)));
|
||||
await server.WaitAssertion(() => Assert.That(loader.TryLoadGeneric(pathCombined, out result, opts)));
|
||||
Assert.That(result!.Category, Is.EqualTo(FileCategory.Unknown));
|
||||
Assert.That(result.Grids, Has.Count.EqualTo(2));
|
||||
Assert.That(result.Maps, Has.Count.EqualTo(2));
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Timing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
@@ -34,7 +33,6 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var cEntManager = client.ResolveDependency<IEntityManager>();
|
||||
var clientNetManager = client.ResolveDependency<IClientNetManager>();
|
||||
|
||||
var sMapManager = server.ResolveDependency<IMapManager>();
|
||||
var sEntManager = server.ResolveDependency<IEntityManager>();
|
||||
var sPlayerManager = server.ResolveDependency<IPlayerManager>();
|
||||
|
||||
@@ -140,6 +138,10 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
Assert.That(!cContainerSys.ExpectedEntities.ContainsKey(sEntManager.GetNetEntity(itemUid)));
|
||||
Assert.That(cContainerSys.ExpectedEntities, Is.Empty);
|
||||
});
|
||||
|
||||
await client.WaitPost(() => clientNetManager.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -279,6 +281,10 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
Assert.That(!cContainerSys.ExpectedEntities.ContainsKey(netEnt));
|
||||
Assert.That(cContainerSys.ExpectedEntities.Count, Is.EqualTo(0));
|
||||
});
|
||||
|
||||
await client.WaitPost(() => clientNetManager.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -138,6 +138,10 @@ public sealed partial class ComponentStateTests : RobustIntegrationTest
|
||||
await client!.WaitRunTicks(1);
|
||||
}
|
||||
}
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -276,6 +280,10 @@ public sealed partial class ComponentStateTests : RobustIntegrationTest
|
||||
await client!.WaitRunTicks(1);
|
||||
}
|
||||
}
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ public sealed class DeletionNetworkingTests : RobustIntegrationTest
|
||||
EntityUid grid2 = default;
|
||||
NetEntity grid1Net = default;
|
||||
NetEntity grid2Net = default;
|
||||
mapSys.CreateMap(out var mapId);
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
mapSys.CreateMap(out var mapId);
|
||||
var gridComp = mapMan.CreateGridEntity(mapId);
|
||||
mapSys.SetTile(gridComp, Vector2i.Zero, new Tile(1));
|
||||
grid1 = gridComp.Owner;
|
||||
@@ -216,6 +216,10 @@ public sealed class DeletionNetworkingTests : RobustIntegrationTest
|
||||
// Was never explicitly deleted by the client.
|
||||
Assert.That(cEntMan.EntityExists(clientChildA));
|
||||
});
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,10 @@ public sealed partial class NoSharedReferencesTest : RobustIntegrationTest
|
||||
await client.WaitRunTicks(1);
|
||||
}
|
||||
}
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ public sealed class GridDeleteSingleTileRemoveTestTest : RobustIntegrationTest
|
||||
var sEntMan = server.ResolveDependency<IEntityManager>();
|
||||
var confMan = server.ResolveDependency<IConfigurationManager>();
|
||||
var sPlayerMan = server.ResolveDependency<ISharedPlayerManager>();
|
||||
var xforms = sEntMan.System<SharedTransformSystem>();
|
||||
var stateMan = (ClientGameStateManager) client.ResolveDependency<IClientGameStateManager>();
|
||||
|
||||
var cEntMan = client.ResolveDependency<IEntityManager>();
|
||||
var netMan = client.ResolveDependency<IClientNetManager>();
|
||||
@@ -135,5 +133,9 @@ public sealed class GridDeleteSingleTileRemoveTestTest : RobustIntegrationTest
|
||||
// Entity should now be parented to the map
|
||||
Assert.That(sQuery.GetComponent(sEntity).ParentUid, Is.EqualTo(sMap));
|
||||
Assert.That(cQuery.GetComponent(cEntity.Value).ParentUid, Is.EqualTo(cMap));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ public sealed class DisconnectTest : RobustIntegrationTest
|
||||
await client.WaitRunTicks(1);
|
||||
}
|
||||
}
|
||||
|
||||
await client.WaitPost(() => cNetMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,10 @@ public sealed class BroadphaseNetworkingTest : RobustIntegrationTest
|
||||
Assert.That(cPlayerXform.Broadphase?.Static, Is.EqualTo(broadphase.Static));
|
||||
Assert.That(cPlayerXform.Broadphase?.CanCollide, Is.EqualTo(broadphase.CanCollide));
|
||||
Assert.That(sPlayerXform.Broadphase, Is.EqualTo(broadphase));
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -397,6 +397,10 @@ public sealed class CollisionPredictionTest : RobustIntegrationTest
|
||||
Assert.That(sSys.CollisionEnded, Is.False);
|
||||
Assert.That(cSys.CollisionEnded, Is.False);
|
||||
}
|
||||
|
||||
await client.WaitPost(() => netMan.ClientDisconnect(""));
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,5 @@ public sealed class SpawnInContainerOrDropTest : EntitySpawnHelpersTest
|
||||
});
|
||||
|
||||
await Server.WaitPost(() => MapSys.DeleteMap(MapId));
|
||||
Server.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,5 @@ public sealed class SpawnNextToOrDropTest : EntitySpawnHelpersTest
|
||||
});
|
||||
|
||||
await Server.WaitPost(() => MapSys.DeleteMap(MapId));
|
||||
Server.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,5 @@ public sealed class TrySpawnInContainerTest : EntitySpawnHelpersTest
|
||||
});
|
||||
|
||||
await Server.WaitPost(() => MapSys.DeleteMap(MapId));
|
||||
Server.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,5 @@ public sealed class TrySpawnNextToTest : EntitySpawnHelpersTest
|
||||
});
|
||||
|
||||
await Server.WaitPost(() => MapSys.DeleteMap(MapId));
|
||||
Server.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ public abstract class ToolshedTest : RobustIntegrationTest, IInvocationContext
|
||||
{
|
||||
protected virtual bool AssertOnUnexpectedError => true;
|
||||
|
||||
#pragma warning disable NUnit1032
|
||||
protected ServerIntegrationInstance Server = default!;
|
||||
#pragma warning restore NUnit1032
|
||||
|
||||
public ToolshedManager Toolshed { get; private set; } = default!;
|
||||
public ToolshedEnvironment Environment => Toolshed.DefaultEnvironment;
|
||||
@@ -30,7 +32,8 @@ public abstract class ToolshedTest : RobustIntegrationTest, IInvocationContext
|
||||
public async Task TearDownInternal()
|
||||
{
|
||||
await TearDown();
|
||||
Server.Dispose();
|
||||
await ReturnToPool(Server);
|
||||
Server = default!;
|
||||
}
|
||||
|
||||
protected virtual Task TearDown()
|
||||
|
||||
Reference in New Issue
Block a user