diff --git a/Content.Benchmarks/IntegrationTestHelpers.cs b/Content.Benchmarks/IntegrationTestHelpers.cs new file mode 100644 index 0000000000..ff2250c5ea --- /dev/null +++ b/Content.Benchmarks/IntegrationTestHelpers.cs @@ -0,0 +1,13 @@ +using Robust.Shared; + +namespace Content.Benchmarks; + +public static class IntegrationTestHelpers +{ + // TODO this is a super dumb hack in order to be able to launch from /Modules folder + // But it works somehow... + public static void ChangeRootDir(string dir) + { + ProgramShared.PathOffset = dir; + } +} diff --git a/Content.IntegrationTests/Content.IntegrationTests.csproj b/Content.IntegrationTests/Content.IntegrationTests.csproj index 328183d8c3..943f2b44a6 100644 --- a/Content.IntegrationTests/Content.IntegrationTests.csproj +++ b/Content.IntegrationTests/Content.IntegrationTests.csproj @@ -24,5 +24,5 @@ - + diff --git a/Content.IntegrationTests/PoolManager.Modules.cs b/Content.IntegrationTests/PoolManager.Modules.cs index 91122c3709..b7f7973c12 100644 --- a/Content.IntegrationTests/PoolManager.Modules.cs +++ b/Content.IntegrationTests/PoolManager.Modules.cs @@ -68,7 +68,13 @@ private static void LoadExtras() var dir = Path.GetDirectoryName(CurrentAssembly.Location); if (string.IsNullOrEmpty(dir)) return; - var modulesPath = Path.Combine(dir, "..", "..", "Modules"); + + // If we are already in the Modules/ folder, the path should be different + var isModule = File.Exists(Path.Combine(dir, "..", "..", "..", "module.yml")); + var modulesPath = isModule + ? Path.Combine(dir, "..", "..", "..", "..", "..", "Modules") + : Path.Combine(dir, "..", "..", "Modules"); + if (Directory.Exists(modulesPath)) LoadModulesFromDirectory(modulesPath, dir); } diff --git a/Content.IntegrationTests/PoolManagerHelpers.cs b/Content.IntegrationTests/PoolManagerHelpers.cs new file mode 100644 index 0000000000..855e08e5b9 --- /dev/null +++ b/Content.IntegrationTests/PoolManagerHelpers.cs @@ -0,0 +1,27 @@ +namespace Content.IntegrationTests; + +public static class PoolManagerHelpers +{ + // This value is completely arbitrary. + private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(30); + private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1)); + + public static void Setup() + { + PoolManager.Startup(); + // If the tests seem to be stuck, we try to end it semi-nicely + _ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ => + { + // This can and probably will cause server/client pairs to shut down MID test, and will lead to really confusing test failures. + TestContext.Error.WriteLine($"\n\n{nameof(PoolManagerTestEventHandler)}: ERROR: Tests are taking too long. Shutting down all tests. This may lead to weird failures/exceptions.\n\n"); + PoolManager.Shutdown(); + }); + + // If ending it nicely doesn't work within a minute, we do something a bit meaner. + _ = Task.Delay(HardStopTimeLimit).ContinueWith(_ => + { + var deathReport = PoolManager.DeathReport(); + Environment.FailFast($"Tests are TAKING TOO LONG!\n Death Report:\n{deathReport}"); + }); + } +} diff --git a/Content.IntegrationTests/PoolManagerTestEventHandler.cs b/Content.IntegrationTests/PoolManagerTestEventHandler.cs index 3b8f6aecae..0a57c133ea 100644 --- a/Content.IntegrationTests/PoolManagerTestEventHandler.cs +++ b/Content.IntegrationTests/PoolManagerTestEventHandler.cs @@ -3,28 +3,12 @@ namespace Content.IntegrationTests; [SetUpFixture] public sealed class PoolManagerTestEventHandler { - // This value is completely arbitrary. - private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(30); - private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1)); + // Goobstation edit - migrated the code to PoolManagerHelpers [OneTimeSetUp] public void Setup() { - PoolManager.Startup(); - // If the tests seem to be stuck, we try to end it semi-nicely - _ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ => - { - // This can and probably will cause server/client pairs to shut down MID test, and will lead to really confusing test failures. - TestContext.Error.WriteLine($"\n\n{nameof(PoolManagerTestEventHandler)}: ERROR: Tests are taking too long. Shutting down all tests. This may lead to weird failures/exceptions.\n\n"); - PoolManager.Shutdown(); - }); - - // If ending it nicely doesn't work within a minute, we do something a bit meaner. - _ = Task.Delay(HardStopTimeLimit).ContinueWith(_ => - { - var deathReport = PoolManager.DeathReport(); - Environment.FailFast($"Tests are TAKING TOO LONG!\n Death Report:\n{deathReport}"); - }); + PoolManagerHelpers.Setup(); } [OneTimeTearDown] diff --git a/Content.MapRenderer/Content.MapRenderer.csproj b/Content.MapRenderer/Content.MapRenderer.csproj index 7d768496ec..743075348a 100644 --- a/Content.MapRenderer/Content.MapRenderer.csproj +++ b/Content.MapRenderer/Content.MapRenderer.csproj @@ -26,5 +26,5 @@ - + diff --git a/Content.YAMLLinter/Content.YAMLLinter.csproj b/Content.YAMLLinter/Content.YAMLLinter.csproj index 00064f8f95..310028137a 100644 --- a/Content.YAMLLinter/Content.YAMLLinter.csproj +++ b/Content.YAMLLinter/Content.YAMLLinter.csproj @@ -28,5 +28,5 @@ - + diff --git a/MSBuild/AllModules.targets b/MSBuild/AllModules.targets new file mode 100644 index 0000000000..67e8cdb08c --- /dev/null +++ b/MSBuild/AllModules.targets @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/MSBuild/TestModules.targets b/MSBuild/TestModules.targets index 3d91cc262e..90e5200b40 100644 --- a/MSBuild/TestModules.targets +++ b/MSBuild/TestModules.targets @@ -3,10 +3,7 @@ - - - - + + + false + disable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modules/GoobStation/Content.Goobstation.IntegrationTests/GlobalUsings.cs b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GlobalUsings.cs new file mode 100644 index 0000000000..1139d45dba --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,6 @@ +// Global usings for Content.IntegrationTests + +global using NUnit.Framework; +global using System; +global using System.Threading.Tasks; +global using Robust.UnitTesting.Pool; diff --git a/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobTest.cs b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobTest.cs new file mode 100644 index 0000000000..478b9d14cf --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobTest.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using Content.IntegrationTests.Fixtures; +using NUnit.Framework; + +namespace Content.Goobstation.IntegrationTests; + +[TestFixture] +public sealed partial class GoobTest : GameTest +{ + [Test] + public async Task TestLoadAll() + { + Server.Log.Debug("Server: If you see this, test did launch!"); + Client.Log.Debug("Client: If you see this, test did launch!"); + } +} diff --git a/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobstationPoolManagerTestEventHandler.cs b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobstationPoolManagerTestEventHandler.cs new file mode 100644 index 0000000000..ccbc4a9613 --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.IntegrationTests/GoobstationPoolManagerTestEventHandler.cs @@ -0,0 +1,21 @@ +using Content.Benchmarks; +using Content.IntegrationTests; + +namespace Content.Goobstation.IntegrationTests; + +[SetUpFixture] +public sealed class GoobstationPoolManagerTestEventHandler +{ + [OneTimeSetUp] + public void Setup() + { + IntegrationTestHelpers.ChangeRootDir("../../../"); + PoolManagerHelpers.Setup(); + } + + [OneTimeTearDown] + public void TearDown() + { + PoolManager.Shutdown(); + } +} diff --git a/SpaceStation14.slnx b/SpaceStation14.slnx index 7c1a65015a..1912656af8 100644 --- a/SpaceStation14.slnx +++ b/SpaceStation14.slnx @@ -18,6 +18,7 @@ + @@ -34,6 +35,7 @@ +