From d4c8ddb0ac6fbbea7aa8f92880c26c5376377433 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Sun, 23 Mar 2025 06:07:01 -0400 Subject: [PATCH] Fix migrations not being applied to PostMapInitTest (#35933) * Fix migrations not being applied to PostMapInitTest * formatting * Raise the event outside the loop so it only happens once --- .../Tests/PostMapInitTest.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index 177161d587..d76297b990 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -22,6 +22,7 @@ using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.IoC; using Robust.Shared.Utility; using YamlDotNet.RepresentationModel; +using Robust.Shared.Map.Events; namespace Content.IntegrationTests.Tests { @@ -223,9 +224,12 @@ namespace Content.IntegrationTests.Tests } var deps = server.ResolveDependency().DependencyCollection; + var ev = new BeforeEntityReadEvent(); + server.EntMan.EventBus.RaiseEvent(EventSource.Local, ev); + foreach (var map in v7Maps) { - Assert.That(IsPreInit(map, loader, deps)); + Assert.That(IsPreInit(map, loader, deps, ev.RenamedPrototypes, ev.DeletedPrototypes)); } // Check that the test actually does manage to catch post-init maps and isn't just blindly passing everything. @@ -238,12 +242,12 @@ namespace Content.IntegrationTests.Tests // First check that a pre-init version passes var path = new ResPath($"{nameof(NoSavedPostMapInitTest)}.yml"); Assert.That(loader.TrySaveMap(id, path)); - Assert.That(IsPreInit(path, loader, deps)); + Assert.That(IsPreInit(path, loader, deps, ev.RenamedPrototypes, ev.DeletedPrototypes)); // and the post-init version fails. await server.WaitPost(() => mapSys.InitializeMap(id)); Assert.That(loader.TrySaveMap(id, path)); - Assert.That(IsPreInit(path, loader, deps), Is.False); + Assert.That(IsPreInit(path, loader, deps, ev.RenamedPrototypes, ev.DeletedPrototypes), Is.False); await pair.CleanReturnAsync(); } @@ -276,7 +280,11 @@ namespace Content.IntegrationTests.Tests }); } - private bool IsPreInit(ResPath map, MapLoaderSystem loader, IDependencyCollection deps) + private bool IsPreInit(ResPath map, + MapLoaderSystem loader, + IDependencyCollection deps, + Dictionary renamedPrototypes, + HashSet deletedPrototypes) { if (!loader.TryReadFile(map, out var data)) { @@ -284,7 +292,12 @@ namespace Content.IntegrationTests.Tests return false; } - var reader = new EntityDeserializer(deps, data, DeserializationOptions.Default); + var reader = new EntityDeserializer(deps, + data, + DeserializationOptions.Default, + renamedPrototypes, + deletedPrototypes); + if (!reader.TryProcessData()) { Assert.Fail($"Failed to process {map}"); -- 2.51.2