]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix test threading (#31669)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 31 Aug 2024 02:35:30 +0000 (12:35 +1000)
committerGitHub <noreply@github.com>
Sat, 31 Aug 2024 02:35:30 +0000 (12:35 +1000)
Content.IntegrationTests/Tests/Actions/ActionPvsDetachTest.cs
Content.IntegrationTests/Tests/Buckle/BuckleDragTest.cs
Content.IntegrationTests/Tests/CargoTest.cs
Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs
Content.IntegrationTests/Tests/Shuttle/DockTest.cs

index 420a90a50bd888c4536059ba9be02c5752686424..b07c352c81dda48a1454acb5e2e9ae0b5f411ff6 100644 (file)
@@ -32,11 +32,16 @@ public sealed class ActionPvsDetachTest
         // PVS-detach action entities
         // We do this by just giving them the ghost layer
         var visSys = server.System<VisibilitySystem>();
-        var enumerator = server.Transform(ent).ChildEnumerator;
-        while (enumerator.MoveNext(out var child))
+
+        await server.WaitPost(() =>
         {
-            visSys.AddLayer(child, (int) VisibilityFlags.Ghost);
-        }
+            var enumerator = server.Transform(ent).ChildEnumerator;
+            while (enumerator.MoveNext(out var child))
+            {
+                visSys.AddLayer(child, (int)VisibilityFlags.Ghost);
+            }
+        });
+
         await pair.RunTicksSync(5);
 
         // Client's actions have left been detached / are out of view, but action comp state has not changed
@@ -44,11 +49,14 @@ public sealed class ActionPvsDetachTest
         Assert.That(cSys.GetActions(cEnt).Count(), Is.EqualTo(initActions));
 
         // Re-enter PVS view
-        enumerator = server.Transform(ent).ChildEnumerator;
-        while (enumerator.MoveNext(out var child))
+        await server.WaitPost(() =>
         {
-            visSys.RemoveLayer(child, (int) VisibilityFlags.Ghost);
-        }
+            var enumerator = server.Transform(ent).ChildEnumerator;
+            while (enumerator.MoveNext(out var child))
+            {
+                visSys.RemoveLayer(child, (int) VisibilityFlags.Ghost);
+            }
+        });
         await pair.RunTicksSync(5);
         Assert.That(sys.GetActions(ent).Count(), Is.EqualTo(initActions));
         Assert.That(cSys.GetActions(cEnt).Count(), Is.EqualTo(initActions));
index 82d5d3baa04c1c13511c2e962306982f3fcc3556..19e8aba1824effbffded80336c19d9285c0a326f 100644 (file)
@@ -34,7 +34,11 @@ public sealed class BuckleDragTest : InteractionTest
         Assert.That(pullable.BeingPulled, Is.False);
 
         // Strap the human to the chair
-        Assert.That(Server.System<SharedBuckleSystem>().TryBuckle(sUrist, SPlayer, STarget.Value));
+        await Server.WaitAssertion(() =>
+        {
+            Assert.That(Server.System<SharedBuckleSystem>().TryBuckle(sUrist, SPlayer, STarget.Value));
+        });
+
         await RunTicks(5);
         Assert.That(buckle.Buckled, Is.True);
         Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
index 89018d9d17c66cca659b3154cea72a124b366a60..1b29e7ea7a99cfe45c66de33bfa63af77726df7a 100644 (file)
@@ -257,9 +257,12 @@ public sealed class CargoTest
         var entManager = server.ResolveDependency<IEntityManager>();
         var priceSystem = entManager.System<PricingSystem>();
 
-        var ent = entManager.SpawnEntity("StackEnt", MapCoordinates.Nullspace);
-        var price = priceSystem.GetPrice(ent);
-        Assert.That(price, Is.EqualTo(100.0));
+        await server.WaitAssertion(() =>
+        {
+            var ent = entManager.SpawnEntity("StackEnt", MapCoordinates.Nullspace);
+            var price = priceSystem.GetPrice(ent);
+            Assert.That(price, Is.EqualTo(100.0));
+        });
 
         await pair.CleanReturnAsync();
     }
index 540e86c650afe2fd91f824bd14704a782c25aa44..e1eef2be4a9d51fbf986661f05499f295b99dfa6 100644 (file)
@@ -143,10 +143,10 @@ public sealed class SuicideCommandTests
             mobStateComp = entManager.GetComponent<MobStateComponent>(player);
             mobThresholdsComp = entManager.GetComponent<MobThresholdsComponent>(player);
             damageableComp = entManager.GetComponent<DamageableComponent>(player);
-        });
 
-        if (protoMan.TryIndex<DamageTypePrototype>("Slash", out var slashProto))
-            damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
+            if (protoMan.TryIndex<DamageTypePrototype>("Slash", out var slashProto))
+                damageableSystem.TryChangeDamage(player, new DamageSpecifier(slashProto, FixedPoint2.New(46.5)));
+        });
 
         // Check that running the suicide command kills the player
         // and properly ghosts them without them being able to return to their body
index a1aa462a6973e38d10e8dd0572858f5877bdd399..f6e99596e90488778a55d1244c1f9abdddc68095 100644 (file)
@@ -97,13 +97,14 @@ public sealed class DockTest : ContentUnitTest
         var entManager = server.ResolveDependency<IEntityManager>();
         var dockingSystem = entManager.System<DockingSystem>();
         var mapSystem = entManager.System<SharedMapSystem>();
+        MapGridComponent mapGrid = default!;
 
-        var mapGrid = entManager.AddComponent<MapGridComponent>(map.MapUid);
         var shuttle = EntityUid.Invalid;
 
         // Spawn shuttle and affirm no valid docks.
         await server.WaitAssertion(() =>
         {
+            mapGrid = entManager.AddComponent<MapGridComponent>(map.MapUid);
             entManager.DeleteEntity(map.Grid);
             Assert.That(entManager.System<MapLoaderSystem>().TryLoad(otherMap.MapId, "/Maps/Shuttles/emergency.yml", out var rootUids));
             shuttle = rootUids[0];