Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test threading #31669

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Content.IntegrationTests/Tests/Actions/ActionPvsDetachTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,31 @@ public async Task TestActionDetach()
// 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
Assert.That(sys.GetActions(ent).Count(), Is.EqualTo(initActions));
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));
Expand Down
6 changes: 5 additions & 1 deletion Content.IntegrationTests/Tests/Buckle/BuckleDragTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public async Task BucklePullTest()
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));
Expand Down
9 changes: 6 additions & 3 deletions Content.IntegrationTests/Tests/CargoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ public async Task StackPrice()
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ await server.WaitPost(() =>
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
Expand Down
3 changes: 2 additions & 1 deletion Content.IntegrationTests/Tests/Shuttle/DockTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ public async Task TestPlanetDock()
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];
Expand Down
Loading