Skip to content
Open
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
13 changes: 13 additions & 0 deletions Content.Benchmarks/IntegrationTestHelpers.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Content.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
<Import Project="..\RobustToolbox\Imports\Shared.props" />
<Import Project="..\RobustToolbox\Imports\Testing.props" />

<Import Project="..\MSBuild\TestModules.targets" />
<Import Project="..\MSBuild\AllModules.targets" />
</Project>
8 changes: 7 additions & 1 deletion Content.IntegrationTests/PoolManager.Modules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
27 changes: 27 additions & 0 deletions Content.IntegrationTests/PoolManagerHelpers.cs
Original file line number Diff line number Diff line change
@@ -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}");
});
}
}
20 changes: 2 additions & 18 deletions Content.IntegrationTests/PoolManagerTestEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Content.MapRenderer/Content.MapRenderer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
<Import Project="..\RobustToolbox\Imports\Shared.props" />
<Import Project="..\RobustToolbox\Imports\Testing.props" />

<Import Project="..\MSBuild\TestModules.targets" />
<Import Project="..\MSBuild\AllModules.targets" />
</Project>
2 changes: 1 addition & 1 deletion Content.YAMLLinter/Content.YAMLLinter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
<Import Project="..\RobustToolbox\Imports\Shared.props" />
<Import Project="..\RobustToolbox\Imports\Testing.props" />

<Import Project="..\MSBuild\TestModules.targets" />
<Import Project="..\MSBuild\AllModules.targets" />
</Project>
25 changes: 25 additions & 0 deletions MSBuild/AllModules.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project>
<!-- Module loading for all modules -->

<Target Name="CompileAndCopyModules" AfterTargets="Build">
<ItemGroup>
<ModuleProjects Include="../Modules/**/Content.*.Shared.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Server.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Server.Database.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Client.csproj" />
</ItemGroup>

<MSBuild Projects="@(ModuleProjects)"
Properties="BuildProjectReferences=false;IsBuildingModules=true"
BuildInParallel="true">
<Output TaskParameter="TargetOutputs" ItemName="ModuleAssemblies" />
</MSBuild>

<ItemGroup>
<ModuleAssemblies Remove="@(ModuleAssemblies)" Condition="'%(Filename)' == 'Content.ModuleManager'" />
</ItemGroup>

<Copy SourceFiles="@(ModuleAssemblies)"
DestinationFolder="$(OutDir)" />
</Target>
</Project>
5 changes: 1 addition & 4 deletions MSBuild/TestModules.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

<Target Name="CompileAndCopyModules" AfterTargets="Build">
<ItemGroup>
<ModuleProjects Include="../Modules/**/Content.*.Shared.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Server.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Server.Database.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.Client.csproj" />
<ModuleProjects Include="../Modules/**/Content.*.IntegrationTests.csproj" />
</ItemGroup>

<MSBuild Projects="@(ModuleProjects)"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[assembly: Parallelizable(ParallelScope.Children)]

// I don't know why this parallelism limit was originally put here.
// I *do* know that I tried removing it, and ran into the following .NET runtime problem:
// https://github.com/dotnet/runtime/issues/107197
// So we can't really parallelize integration tests harder either until the runtime fixes that,
// *or* we fix serv3 to not spam expression trees.
[assembly: LevelOfParallelism(2)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>disable</Nullable>
</PropertyGroup>
<Import Project="../../../MSBuild/Content.props" />

<ItemGroup>
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Content.Benchmarks\Content.Benchmarks.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Content.Goobstation.Client\Content.Goobstation.Client.csproj" />
<ProjectReference Include="..\Content.Goobstation.Server\Content.Goobstation.Server.csproj" />
</ItemGroup>

<Import Project="..\..\..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<Import Project="..\..\..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" />

<Import Project="..\..\..\RobustToolbox\Imports\Client.props" />
<Import Project="..\..\..\RobustToolbox\Imports\Server.props" />
<Import Project="..\..\..\RobustToolbox\Imports\Shared.props" />
<Import Project="..\..\..\RobustToolbox\Imports\Testing.props" />

<Import Project="..\..\..\MSBuild\AllModules.targets" />
<Import Project="..\..\..\MSBuild\TestModules.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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!");
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
2 changes: 2 additions & 0 deletions SpaceStation14.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Project Path="Modules/GoobStation/Content.Goobstation.Client/Content.Goobstation.Client.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.Client.UIKit/Content.Goobstation.Client.UIKit.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.Common/Content.Goobstation.Common.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.IntegrationTests/Content.Goobstation.IntegrationTests.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.Server.Database/Content.Goobstation.Server.Database.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.Server/Content.Goobstation.Server.csproj" />
<Project Path="Modules/GoobStation/Content.Goobstation.Shared/Content.Goobstation.Shared.csproj" />
Expand All @@ -34,6 +35,7 @@
<File Path="MSBuild/Content.props" />
<File Path="MSBuild/ClientModules.targets" />
<File Path="MSBuild/ServerModules.targets" />
<File Path="MSBuild/AllModules.targets" />
<File Path="MSBuild/TestModules.targets" />
</Folder>
<Folder Name="/Project Files/">
Expand Down
Loading