Remove PoolSettings.ExtraPrototypes option (#18678)

This commit is contained in:
Leon Friedrich
2023-08-05 16:16:48 +12:00
committed by GitHub
parent c2beaff3ac
commit d58786faf4
51 changed files with 463 additions and 399 deletions

View File

@@ -26,10 +26,12 @@ public class DeviceNetworkingBenchmark
private NetworkPayload _payload = default!; private NetworkPayload _payload = default!;
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: DummyNetworkDevice name: DummyNetworkDevicePrivate
id: DummyNetworkDevice id: DummyNetworkDevicePrivate
components: components:
- type: DeviceNetwork - type: DeviceNetwork
transmitFrequency: 100 transmitFrequency: 100
@@ -56,7 +58,7 @@ public class DeviceNetworkingBenchmark
public async Task SetupAsync() public async Task SetupAsync()
{ {
ProgramShared.PathOffset = "../../../../"; ProgramShared.PathOffset = "../../../../";
_pair = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); _pair = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = _pair.Pair.Server; var server = _pair.Pair.Server;
await server.WaitPost(() => await server.WaitPost(() =>
@@ -73,17 +75,23 @@ public class DeviceNetworkingBenchmark
["testbool"] = true ["testbool"] = true
}; };
_sourceEntity = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace); _sourceEntity = entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace);
_sourceWirelessEntity = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace); _sourceWirelessEntity = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
for (var i = 0; i < EntityCount; i++) for (var i = 0; i < EntityCount; i++)
{ {
_targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace)); _targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace));
_targetWirelessEntities.Add(entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace)); _targetWirelessEntities.Add(entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace));
} }
}); });
} }
[GlobalCleanup]
public async Task Cleanup()
{
await _pair.DisposeAsync();
}
[Benchmark(Baseline = true, Description = "Entity Events")] [Benchmark(Baseline = true, Description = "Entity Events")]
public async Task EventSentBaseline() public async Task EventSentBaseline()
{ {

View File

@@ -20,6 +20,7 @@ namespace Content.Benchmarks
public static async Task MainAsync(string[] args) public static async Task MainAsync(string[] args)
{ {
PoolManager.Startup(typeof(Program).Assembly);
var pair = await PoolManager.GetServerClient(); var pair = await PoolManager.GetServerClient();
var gameMaps = pair.Pair.Server.ResolveDependency<IPrototypeManager>().EnumeratePrototypes<GameMapPrototype>().ToList(); var gameMaps = pair.Pair.Server.ResolveDependency<IPrototypeManager>().EnumeratePrototypes<GameMapPrototype>().ToList();
MapLoadBenchmark.MapsSource = gameMaps.Select(x => x.ID); MapLoadBenchmark.MapsSource = gameMaps.Select(x => x.ID);
@@ -33,6 +34,8 @@ namespace Content.Benchmarks
var config = Environment.GetEnvironmentVariable("ROBUST_BENCHMARKS_ENABLE_SQL") != null ? DefaultSQLConfig.Instance : null; var config = Environment.GetEnvironmentVariable("ROBUST_BENCHMARKS_ENABLE_SQL") != null ? DefaultSQLConfig.Instance : null;
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config); BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
#endif #endif
PoolManager.Shutdown();
} }
} }
} }

View File

@@ -0,0 +1,38 @@
#nullable enable
using System.Collections.Generic;
using System.Reflection;
using Robust.Shared.Utility;
namespace Content.IntegrationTests;
// Partial class for handling the discovering and storing test prototypes.
public static partial class PoolManager
{
private static List<string> _testPrototypes = new();
private const BindingFlags Flags = BindingFlags.Static
| BindingFlags.NonPublic
| BindingFlags.Public
| BindingFlags.DeclaredOnly;
private static void DiscoverTestPrototypes(Assembly? assembly = null)
{
assembly ??= typeof(PoolManager).Assembly;
_testPrototypes.Clear();
foreach (var type in assembly.GetTypes())
{
foreach (var field in type.GetFields(Flags))
{
if (!field.HasCustomAttribute<TestPrototypesAttribute>())
continue;
var val = field.GetValue(null);
if (val is not string str)
throw new Exception($"TestPrototypeAttribute is only valid on non-null string fields");
_testPrototypes.Add(str);
}
}
}
}

View File

@@ -1,6 +1,8 @@
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Content.Client.IoC; using Content.Client.IoC;
@@ -27,6 +29,7 @@ using Robust.Shared.Map.Components;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.UnitTesting; using Robust.UnitTesting;
[assembly: LevelOfParallelism(3)] [assembly: LevelOfParallelism(3)]
@@ -36,7 +39,7 @@ namespace Content.IntegrationTests;
/// <summary> /// <summary>
/// Making clients, and servers is slow, this manages a pool of them so tests can reuse them. /// Making clients, and servers is slow, this manages a pool of them so tests can reuse them.
/// </summary> /// </summary>
public static class PoolManager public static partial class PoolManager
{ {
public const string TestMap = "Empty"; public const string TestMap = "Empty";
@@ -62,23 +65,12 @@ public static class PoolManager
private static int _pairId; private static int _pairId;
private static readonly object PairLock = new(); private static readonly object PairLock = new();
private static bool _initialized;
// Pair, IsBorrowed // Pair, IsBorrowed
private static readonly Dictionary<Pair, bool> Pairs = new(); private static readonly Dictionary<Pair, bool> Pairs = new();
private static bool _dead; private static bool _dead;
private static Exception _poolFailureReason; private static Exception? _poolFailureReason;
private static async Task ConfigurePrototypes(RobustIntegrationTest.IntegrationInstance instance,
PoolSettings settings)
{
await instance.WaitPost(() =>
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var changes = new Dictionary<Type, HashSet<string>>();
prototypeManager.LoadString(settings.ExtraPrototypes.Trim(), true, changes);
prototypeManager.ReloadPrototypes(changes);
});
}
private static async Task<(RobustIntegrationTest.ServerIntegrationInstance, PoolTestLogHandler)> GenerateServer( private static async Task<(RobustIntegrationTest.ServerIntegrationInstance, PoolTestLogHandler)> GenerateServer(
PoolSettings poolSettings, PoolSettings poolSettings,
@@ -86,7 +78,6 @@ public static class PoolManager
{ {
var options = new RobustIntegrationTest.ServerIntegrationOptions var options = new RobustIntegrationTest.ServerIntegrationOptions
{ {
ExtraPrototypes = poolSettings.ExtraPrototypes,
ContentStart = true, ContentStart = true,
Options = new ServerOptions() Options = new ServerOptions()
{ {
@@ -144,6 +135,8 @@ public static class PoolManager
{ {
pair.Kill(); pair.Kill();
} }
_initialized = false;
} }
public static string DeathReport() public static string DeathReport()
@@ -174,7 +167,6 @@ public static class PoolManager
{ {
FailureLogLevel = LogLevel.Warning, FailureLogLevel = LogLevel.Warning,
ContentStart = true, ContentStart = true,
ExtraPrototypes = poolSettings.ExtraPrototypes,
ContentAssemblies = new[] ContentAssemblies = new[]
{ {
typeof(Shared.Entry.EntryPoint).Assembly, typeof(Shared.Entry.EntryPoint).Assembly,
@@ -257,7 +249,7 @@ public static class PoolManager
/// </summary> /// </summary>
/// <param name="poolSettings">See <see cref="PoolSettings"/></param> /// <param name="poolSettings">See <see cref="PoolSettings"/></param>
/// <returns></returns> /// <returns></returns>
public static async Task<PairTracker> GetServerClient(PoolSettings poolSettings = null) public static async Task<PairTracker> GetServerClient(PoolSettings? poolSettings = null)
{ {
return await GetServerClientPair(poolSettings ?? new PoolSettings()); return await GetServerClientPair(poolSettings ?? new PoolSettings());
} }
@@ -269,6 +261,9 @@ public static class PoolManager
private static async Task<PairTracker> GetServerClientPair(PoolSettings poolSettings) private static async Task<PairTracker> GetServerClientPair(PoolSettings poolSettings)
{ {
if (!_initialized)
throw new InvalidOperationException($"Pool manager has not been initialized");
// Trust issues with the AsyncLocal that backs this. // Trust issues with the AsyncLocal that backs this.
var testContext = TestContext.CurrentContext; var testContext = TestContext.CurrentContext;
var testOut = TestContext.Out; var testOut = TestContext.Out;
@@ -277,7 +272,7 @@ public static class PoolManager
var currentTestName = poolSettings.TestName ?? GetDefaultTestName(testContext); var currentTestName = poolSettings.TestName ?? GetDefaultTestName(testContext);
var poolRetrieveTimeWatch = new Stopwatch(); var poolRetrieveTimeWatch = new Stopwatch();
await testOut.WriteLineAsync($"{nameof(GetServerClientPair)}: Called by test {currentTestName}"); await testOut.WriteLineAsync($"{nameof(GetServerClientPair)}: Called by test {currentTestName}");
Pair pair = null; Pair? pair = null;
try try
{ {
poolRetrieveTimeWatch.Start(); poolRetrieveTimeWatch.Start();
@@ -386,11 +381,11 @@ public static class PoolManager
Assert.That(status, Is.EqualTo(expected)); Assert.That(status, Is.EqualTo(expected));
} }
private static Pair GrabOptimalPair(PoolSettings poolSettings) private static Pair? GrabOptimalPair(PoolSettings poolSettings)
{ {
lock (PairLock) lock (PairLock)
{ {
Pair fallback = null; Pair? fallback = null;
foreach (var pair in Pairs.Keys) foreach (var pair in Pairs.Keys)
{ {
if (Pairs[pair]) if (Pairs[pair])
@@ -457,7 +452,7 @@ public static class PoolManager
cNetMgr.ClientConnect(null!, 0, null!); cNetMgr.ClientConnect(null!, 0, null!);
}); });
} }
await ReallyBeIdle(pair, 11); await ReallyBeIdle(pair, 5);
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Disconnecting client, and restarting server"); await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Disconnecting client, and restarting server");
@@ -466,43 +461,7 @@ public static class PoolManager
cNetMgr.ClientDisconnect("Test pooling cleanup disconnect"); cNetMgr.ClientDisconnect("Test pooling cleanup disconnect");
}); });
await ReallyBeIdle(pair, 10); await ReallyBeIdle(pair, 5);
if (!string.IsNullOrWhiteSpace(pair.Settings.ExtraPrototypes))
{
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Removing prototypes");
if (!pair.Settings.NoServer)
{
var serverProtoManager = pair.Server.ResolveDependency<IPrototypeManager>();
await pair.Server.WaitPost(() =>
{
serverProtoManager.RemoveString(pair.Settings.ExtraPrototypes.Trim());
});
}
if (!pair.Settings.NoClient)
{
var clientProtoManager = pair.Client.ResolveDependency<IPrototypeManager>();
await pair.Client.WaitPost(() =>
{
clientProtoManager.RemoveString(pair.Settings.ExtraPrototypes.Trim());
});
}
await ReallyBeIdle(pair, 1);
}
if (poolSettings.ExtraPrototypes != null)
{
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Adding prototypes");
if (!poolSettings.NoServer)
{
await ConfigurePrototypes(pair.Server, poolSettings);
}
if (!poolSettings.NoClient)
{
await ConfigurePrototypes(pair.Client, poolSettings);
}
}
configManager.SetCVar(CCVars.GameMap, poolSettings.Map); configManager.SetCVar(CCVars.GameMap, poolSettings.Map);
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Restarting server again"); await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Restarting server again");
@@ -548,6 +507,7 @@ we are just going to end this here to save a lot of time. This is the exception
Assert.Fail("The pool was shut down"); Assert.Fail("The pool was shut down");
} }
} }
private static async Task<Pair> CreateServerClientPair(PoolSettings poolSettings, TextWriter testOut) private static async Task<Pair> CreateServerClientPair(PoolSettings poolSettings, TextWriter testOut)
{ {
Pair pair; Pair pair;
@@ -563,6 +523,9 @@ we are just going to end this here to save a lot of time. This is the exception
ClientLogHandler = clientLog, ClientLogHandler = clientLog,
PairId = Interlocked.Increment(ref _pairId) PairId = Interlocked.Increment(ref _pairId)
}; };
if (!poolSettings.NoLoadTestPrototypes)
await pair.LoadPrototypes(_testPrototypes!);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -757,6 +720,19 @@ we are just going to end this here to save a lot of time. This is the exception
return list; return list;
} }
/// <summary>
/// Initialize the pool manager.
/// </summary>
/// <param name="assembly">Assembly to search for to discover extra test prototypes.</param>
public static void Startup(Assembly? assembly)
{
if (_initialized)
throw new InvalidOperationException("Already initialized");
_initialized = true;
DiscoverTestPrototypes(assembly);
}
} }
/// <summary> /// <summary>
@@ -766,17 +742,15 @@ we are just going to end this here to save a lot of time. This is the exception
/// </summary> /// </summary>
public sealed class PoolSettings public sealed class PoolSettings
{ {
// TODO: We can make more of these pool-able, if we need enough of them for it to matter
/// <summary> /// <summary>
/// If the returned pair must not be reused /// If the returned pair must not be reused
/// </summary> /// </summary>
public bool MustNotBeReused => Destructive || NoLoadContent || NoToolsExtraPrototypes; public bool MustNotBeReused => Destructive || NoLoadContent || NoLoadTestPrototypes;
/// <summary> /// <summary>
/// If the given pair must be brand new /// If the given pair must be brand new
/// </summary> /// </summary>
public bool MustBeNew => Fresh || NoLoadContent || NoToolsExtraPrototypes; public bool MustBeNew => Fresh || NoLoadContent || NoLoadTestPrototypes;
/// <summary> /// <summary>
/// If the given pair must not be connected /// If the given pair must not be connected
@@ -816,9 +790,11 @@ public sealed class PoolSettings
public bool NoLoadContent { get; init; } public bool NoLoadContent { get; init; }
/// <summary> /// <summary>
/// Set this to raw yaml text to load prototypes onto the given server/client pair. /// This will return a server-client pair that has not loaded test prototypes.
/// Try avoiding this whenever possible, as this will always create & destroy a new pair.
/// Use <see cref="Pair.IsTestPrototype(EntityPrototype)"/> if you need to exclude test prototypees.
/// </summary> /// </summary>
public string ExtraPrototypes { get; init; } public bool NoLoadTestPrototypes { get; init; }
/// <summary> /// <summary>
/// Set this to true to disable the NetInterp CVar on the given server/client pair /// Set this to true to disable the NetInterp CVar on the given server/client pair
@@ -848,7 +824,7 @@ public sealed class PoolSettings
/// <summary> /// <summary>
/// Overrides the test name detection, and uses this in the test history instead /// Overrides the test name detection, and uses this in the test history instead
/// </summary> /// </summary>
public string TestName { get; set; } public string? TestName { get; set; }
/// <summary> /// <summary>
/// Tries to guess if we can skip recycling the server/client pair. /// Tries to guess if we can skip recycling the server/client pair.
@@ -870,19 +846,8 @@ public sealed class PoolSettings
return NotConnected == nextSettings.NotConnected return NotConnected == nextSettings.NotConnected
&& DummyTicker == nextSettings.DummyTicker && DummyTicker == nextSettings.DummyTicker
&& Map == nextSettings.Map && Map == nextSettings.Map
&& InLobby == nextSettings.InLobby && InLobby == nextSettings.InLobby;
&& ExtraPrototypes == nextSettings.ExtraPrototypes;
} }
// Prototype hot reload is not available outside TOOLS builds,
// so we can't pool test instances that use ExtraPrototypes without TOOLS.
#if TOOLS
#pragma warning disable CA1822 // Can't be marked as static b/c the other branch exists but Omnisharp can't see both.
private bool NoToolsExtraPrototypes => false;
#pragma warning restore CA1822
#else
private bool NoToolsExtraPrototypes => !string.IsNullOrEmpty(ExtraPrototypes);
#endif
} }
/// <summary> /// <summary>
@@ -893,7 +858,7 @@ public sealed class TestMapData
public EntityUid MapUid { get; set; } public EntityUid MapUid { get; set; }
public EntityUid GridUid { get; set; } public EntityUid GridUid { get; set; }
public MapId MapId { get; set; } public MapId MapId { get; set; }
public MapGridComponent MapGrid { get; set; } public MapGridComponent MapGrid { get; set; } = default!;
public EntityCoordinates GridCoords { get; set; } public EntityCoordinates GridCoords { get; set; }
public MapCoordinates MapCoords { get; set; } public MapCoordinates MapCoords { get; set; }
public TileRef Tile { get; set; } public TileRef Tile { get; set; }
@@ -907,12 +872,15 @@ public sealed class Pair
public bool Dead { get; private set; } public bool Dead { get; private set; }
public int PairId { get; init; } public int PairId { get; init; }
public List<string> TestHistory { get; set; } = new(); public List<string> TestHistory { get; set; } = new();
public PoolSettings Settings { get; set; } public PoolSettings Settings { get; set; } = default!;
public RobustIntegrationTest.ServerIntegrationInstance Server { get; init; } public RobustIntegrationTest.ServerIntegrationInstance Server { get; init; } = default!;
public RobustIntegrationTest.ClientIntegrationInstance Client { get; init; } public RobustIntegrationTest.ClientIntegrationInstance Client { get; init; } = default!;
public PoolTestLogHandler ServerLogHandler { get; init; } public PoolTestLogHandler ServerLogHandler { get; init; } = default!;
public PoolTestLogHandler ClientLogHandler { get; init; } public PoolTestLogHandler ClientLogHandler { get; init; } = default!;
private Dictionary<Type, HashSet<string>> _loadedPrototypes = new();
private HashSet<string> _loadedEntityPrototypes = new();
public void Kill() public void Kill()
{ {
@@ -932,6 +900,57 @@ public sealed class Pair
ServerLogHandler.ActivateContext(testOut); ServerLogHandler.ActivateContext(testOut);
ClientLogHandler.ActivateContext(testOut); ClientLogHandler.ActivateContext(testOut);
} }
public async Task LoadPrototypes(List<string> prototypes)
{
await LoadPrototypes(Server, prototypes);
await LoadPrototypes(Client, prototypes);
}
private async Task LoadPrototypes(RobustIntegrationTest.IntegrationInstance instance, List<string> prototypes)
{
var changed = new Dictionary<Type, HashSet<string>>();
var protoMan = instance.ResolveDependency<IPrototypeManager>();
foreach (var file in prototypes)
{
protoMan.LoadString(file, changed: changed);
}
await instance.WaitPost(() => protoMan.ReloadPrototypes(changed));
foreach (var (kind, ids) in changed)
{
_loadedPrototypes.GetOrNew(kind).UnionWith(ids);
}
if (_loadedPrototypes.TryGetValue(typeof(EntityPrototype), out var entIds))
_loadedEntityPrototypes.UnionWith(entIds);
}
public bool IsTestPrototype(EntityPrototype proto)
{
return _loadedEntityPrototypes.Contains(proto.ID);
}
public bool IsTestEntityPrototype(string id)
{
return _loadedEntityPrototypes.Contains(id);
}
public bool IsTestPrototype<TPrototype>(string id) where TPrototype : IPrototype
{
return IsTestPrototype(typeof(TPrototype), id);
}
public bool IsTestPrototype<TPrototype>(TPrototype proto) where TPrototype : IPrototype
{
return IsTestPrototype(typeof(TPrototype), proto.ID);
}
public bool IsTestPrototype(Type kind, string id)
{
return _loadedPrototypes.TryGetValue(kind, out var ids) && ids.Contains(id);
}
} }
/// <summary> /// <summary>
@@ -941,8 +960,8 @@ public sealed class PairTracker : IAsyncDisposable
{ {
private readonly TextWriter _testOut; private readonly TextWriter _testOut;
private int _disposed; private int _disposed;
public Stopwatch UsageWatch { get; set; } public Stopwatch UsageWatch { get; set; } = default!;
public Pair Pair { get; init; } public Pair Pair { get; init; } = default!;
public PairTracker(TextWriter testOut) public PairTracker(TextWriter testOut)
{ {

View File

@@ -9,9 +9,11 @@ public sealed class PoolManagerTestEventHandler
// This value is completely arbitrary. // This value is completely arbitrary.
private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(20); private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(20);
private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1)); private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1));
[OneTimeSetUp] [OneTimeSetUp]
public void Setup() public void Setup()
{ {
PoolManager.Startup(typeof(PoolManagerTestEventHandler).Assembly);
// If the tests seem to be stuck, we try to end it semi-nicely // If the tests seem to be stuck, we try to end it semi-nicely
_ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ => _ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ =>
{ {

View File

@@ -0,0 +1,9 @@
namespace Content.IntegrationTests;
/// <summary>
/// Attribute that indicates that a string contains yaml prototype data that should be loaded by integration tests.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public sealed class TestPrototypesAttribute : Attribute
{
}

View File

@@ -7,9 +7,10 @@ namespace Content.IntegrationTests.Tests.Atmos
[TestOf(typeof(AtmosAlarmThreshold))] [TestOf(typeof(AtmosAlarmThreshold))]
public sealed class AlarmThresholdTest public sealed class AlarmThresholdTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: alarmThreshold - type: alarmThreshold
id: testThreshold id: AlarmThresholdTestDummy
upperBound: !type:AlarmThresholdSetting upperBound: !type:AlarmThresholdSetting
threshold: 5 threshold: 5
lowerBound: !type:AlarmThresholdSetting lowerBound: !type:AlarmThresholdSetting
@@ -23,7 +24,7 @@ namespace Content.IntegrationTests.Tests.Atmos
[Test] [Test]
public async Task TestAlarmThreshold() public async Task TestAlarmThreshold()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var prototypeManager = server.ResolveDependency<IPrototypeManager>(); var prototypeManager = server.ResolveDependency<IPrototypeManager>();
@@ -31,7 +32,7 @@ namespace Content.IntegrationTests.Tests.Atmos
await server.WaitPost(() => await server.WaitPost(() =>
{ {
threshold = prototypeManager.Index<AtmosAlarmThreshold>("testThreshold"); threshold = prototypeManager.Index<AtmosAlarmThreshold>("AlarmThresholdTestDummy");
}); });
await server.WaitAssertion(() => await server.WaitAssertion(() =>

View File

@@ -14,6 +14,7 @@ namespace Content.IntegrationTests.Tests.Body
[TestOf(typeof(BodyComponent))] [TestOf(typeof(BodyComponent))]
public sealed class LegTest public sealed class LegTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanBodyAndAppearanceDummy name: HumanBodyAndAppearanceDummy
@@ -30,8 +31,7 @@ namespace Content.IntegrationTests.Tests.Body
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -19,10 +19,11 @@ namespace Content.IntegrationTests.Tests.Body
[TestOf(typeof(LungSystem))] [TestOf(typeof(LungSystem))]
public sealed class LungTest public sealed class LungTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanBodyDummy name: HumanLungDummy
id: HumanBodyDummy id: HumanLungDummy
components: components:
- type: SolutionContainerManager - type: SolutionContainerManager
- type: Body - type: Body
@@ -54,8 +55,7 @@ namespace Content.IntegrationTests.Tests.Body
// --- Setup // --- Setup
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -104,7 +104,7 @@ namespace Content.IntegrationTests.Tests.Body
{ {
var coords = new Vector2(0.5f, -1f); var coords = new Vector2(0.5f, -1f);
var coordinates = new EntityCoordinates(grid.Value, coords); var coordinates = new EntityCoordinates(grid.Value, coords);
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates); human = entityManager.SpawnEntity("HumanLungDummy", coordinates);
respSys = entityManager.System<RespiratorSystem>(); respSys = entityManager.System<RespiratorSystem>();
metaSys = entityManager.System<MetabolizerSystem>(); metaSys = entityManager.System<MetabolizerSystem>();
relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(grid.Value); relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(grid.Value);
@@ -143,8 +143,7 @@ namespace Content.IntegrationTests.Tests.Body
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -179,7 +178,7 @@ namespace Content.IntegrationTests.Tests.Body
var center = new Vector2(0.5f, 0.5f); var center = new Vector2(0.5f, 0.5f);
var coordinates = new EntityCoordinates(grid.Value, center); var coordinates = new EntityCoordinates(grid.Value, center);
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates); human = entityManager.SpawnEntity("HumanLungDummy", coordinates);
var mixture = entityManager.System<AtmosphereSystem>().GetContainingMixture(human); var mixture = entityManager.System<AtmosphereSystem>().GetContainingMixture(human);
#pragma warning disable NUnit2045 #pragma warning disable NUnit2045

View File

@@ -11,6 +11,7 @@ namespace Content.IntegrationTests.Tests.Body;
[TestFixture] [TestFixture]
public sealed class SaveLoadReparentTest public sealed class SaveLoadReparentTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanBodyDummy name: HumanBodyDummy
@@ -25,8 +26,7 @@ public sealed class SaveLoadReparentTest
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -21,7 +21,8 @@ namespace Content.IntegrationTests.Tests.Buckle
private const string StrapDummyId = "StrapDummy"; private const string StrapDummyId = "StrapDummy";
private const string ItemDummyId = "ItemDummy"; private const string ItemDummyId = "ItemDummy";
private static readonly string Prototypes = $@" [TestPrototypes]
private const string Prototypes = $@"
- type: entity - type: entity
name: {BuckleDummyId} name: {BuckleDummyId}
id: {BuckleDummyId} id: {BuckleDummyId}
@@ -49,7 +50,7 @@ namespace Content.IntegrationTests.Tests.Buckle
public async Task BuckleUnbuckleCooldownRangeTest() public async Task BuckleUnbuckleCooldownRangeTest()
{ {
await using var pairTracker = await using var pairTracker =
await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes }); await PoolManager.GetServerClient();
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker); var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -244,8 +245,7 @@ namespace Content.IntegrationTests.Tests.Buckle
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -341,8 +341,7 @@ namespace Content.IntegrationTests.Tests.Buckle
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -109,6 +109,7 @@ public sealed class CargoTest
var protoIds = protoManager.EnumeratePrototypes<EntityPrototype>() var protoIds = protoManager.EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract) .Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // Grids are not for sale. .Where(p => !p.Components.ContainsKey("MapGrid")) // Grids are not for sale.
.Select(p => p.ID) .Select(p => p.ID)
.ToList(); .ToList();
@@ -144,10 +145,9 @@ public sealed class CargoTest
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }
[Test]
public async Task StackPrice() [TestPrototypes]
{ private const string StackProto = @"
const string stackProto = @"
- type: entity - type: entity
id: A id: A
@@ -165,7 +165,11 @@ public sealed class CargoTest
count: 5 count: 5
"; ";
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = stackProto }); [Test]
public async Task StackPrice()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true } );
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var entManager = server.ResolveDependency<IEntityManager>(); var entManager = server.ResolveDependency<IEntityManager>();

View File

@@ -14,6 +14,7 @@ namespace Content.IntegrationTests.Tests.Chemistry;
[TestOf(typeof(SolutionContainerSystem))] [TestOf(typeof(SolutionContainerSystem))]
public sealed class SolutionSystemTests public sealed class SolutionSystemTests
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: SolutionTarget id: SolutionTarget
@@ -47,8 +48,7 @@ public sealed class SolutionSystemTests
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -95,8 +95,7 @@ public sealed class SolutionSystemTests
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -143,8 +142,7 @@ public sealed class SolutionSystemTests
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -202,8 +200,7 @@ public sealed class SolutionSystemTests
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -241,7 +238,7 @@ public sealed class SolutionSystemTests
[Test] [Test]
public async Task TestTemperatureCalculations() public async Task TestTemperatureCalculations()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>(); var protoMan = server.ResolveDependency<IPrototypeManager>();
const float temp = 100.0f; const float temp = 100.0f;

View File

@@ -13,6 +13,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
[TestOf(typeof(ReactionPrototype))] [TestOf(typeof(ReactionPrototype))]
public sealed class TryAllReactionsTest public sealed class TryAllReactionsTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: TestSolutionContainer id: TestSolutionContainer
@@ -22,13 +23,13 @@ namespace Content.IntegrationTests.Tests.Chemistry
beaker: beaker:
maxVol: 50 maxVol: 50
canMix: true"; canMix: true";
[Test] [Test]
public async Task TryAllTest() public async Task TryAllTest()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -15,6 +15,7 @@ namespace Content.IntegrationTests.Tests.Commands
[TestOf(typeof(RejuvenateSystem))] [TestOf(typeof(RejuvenateSystem))]
public sealed class RejuvenateTest public sealed class RejuvenateTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: DamageableDummy name: DamageableDummy
@@ -34,8 +35,7 @@ namespace Content.IntegrationTests.Tests.Commands
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var entManager = server.ResolveDependency<IEntityManager>(); var entManager = server.ResolveDependency<IEntityManager>();

View File

@@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.Construction
{ {
foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.Abstract || !proto.Components.TryGetValue(name, out var reg)) if (proto.Abstract || pairTracker.Pair.IsTestPrototype(proto) || !proto.Components.TryGetValue(name, out var reg))
continue; continue;
var comp = (ConstructionComponent) reg.Component; var comp = (ConstructionComponent) reg.Component;

View File

@@ -9,6 +9,7 @@ namespace Content.IntegrationTests.Tests
{ {
public sealed class ContainerOcclusionTest public sealed class ContainerOcclusionTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: ContainerOcclusionA id: ContainerOcclusionA
@@ -33,7 +34,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestA() public async Task TestA()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient();
var s = pairTracker.Pair.Server; var s = pairTracker.Pair.Server;
var c = pairTracker.Pair.Client; var c = pairTracker.Pair.Client;
@@ -73,7 +74,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestB() public async Task TestB()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient();
var s = pairTracker.Pair.Server; var s = pairTracker.Pair.Server;
var c = pairTracker.Pair.Client; var c = pairTracker.Pair.Client;
@@ -113,7 +114,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestAb() public async Task TestAb()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient();
var s = pairTracker.Pair.Server; var s = pairTracker.Pair.Server;
var c = pairTracker.Pair.Client; var c = pairTracker.Pair.Client;

View File

@@ -14,7 +14,8 @@ namespace Content.IntegrationTests.Tests.Damageable
[TestOf(typeof(DamageableSystem))] [TestOf(typeof(DamageableSystem))]
public sealed class DamageableTest public sealed class DamageableTest
{ {
public const string Prototypes = @" [TestPrototypes]
private const string Prototypes = @"
# Define some damage groups # Define some damage groups
- type: damageType - type: damageType
id: TestDamage1 id: TestDamage1
@@ -74,8 +75,7 @@ namespace Content.IntegrationTests.Tests.Damageable
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -20,8 +20,7 @@ namespace Content.IntegrationTests.Tests.Destructible
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -17,8 +17,7 @@ namespace Content.IntegrationTests.Tests.Destructible
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -16,8 +16,7 @@ namespace Content.IntegrationTests.Tests.Destructible
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -8,7 +8,8 @@ namespace Content.IntegrationTests.Tests.Destructible
public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity"; public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity";
public const string DestructibleDamageGroupEntityId = "DestructibleTestsDestructibleDamageGroupEntity"; public const string DestructibleDamageGroupEntityId = "DestructibleTestsDestructibleDamageGroupEntity";
public static readonly string Prototypes = $@" [TestPrototypes]
public const string DamagePrototypes = $@"
- type: damageType - type: damageType
id: TestBlunt id: TestBlunt

View File

@@ -22,8 +22,7 @@ namespace Content.IntegrationTests.Tests.Destructible
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -15,6 +15,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
[TestOf(typeof(WirelessNetworkComponent))] [TestOf(typeof(WirelessNetworkComponent))]
public sealed class DeviceNetworkTest public sealed class DeviceNetworkTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: DummyNetworkDevice name: DummyNetworkDevice
@@ -36,8 +37,8 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
- type: ApcPowerReceiver - type: ApcPowerReceiver
- type: entity - type: entity
name: DummyWirelessNetworkDevice name: WirelessNetworkDeviceDummy
id: DummyWirelessNetworkDevice id: WirelessNetworkDeviceDummy
components: components:
- type: DeviceNetwork - type: DeviceNetwork
transmitFrequency: 100 transmitFrequency: 100
@@ -52,8 +53,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -116,8 +116,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker); var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -144,7 +143,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
device1 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", coordinates); device1 = entityManager.SpawnEntity("WirelessNetworkDeviceDummy", coordinates);
Assert.Multiple(() => Assert.Multiple(() =>
{ {
@@ -157,7 +156,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty));
}); });
device2 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", new MapCoordinates(new Vector2(0, 50), testMap.MapId)); device2 = entityManager.SpawnEntity("WirelessNetworkDeviceDummy", new MapCoordinates(new Vector2(0, 50), testMap.MapId));
Assert.That(entityManager.TryGetComponent(device2, out networkComponent2), Is.True); Assert.That(entityManager.TryGetComponent(device2, out networkComponent2), Is.True);
Assert.Multiple(() => Assert.Multiple(() =>
@@ -205,8 +204,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker); var testMap = await PoolManager.CreateTestMap(pairTracker);

View File

@@ -72,10 +72,11 @@ namespace Content.IntegrationTests.Tests.Disposal
}); });
} }
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanDummy name: HumanDisposalDummy
id: HumanDummy id: HumanDisposalDummy
components: components:
- type: Body - type: Body
prototype: Human prototype: Human
@@ -148,8 +149,7 @@ namespace Content.IntegrationTests.Tests.Disposal
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -171,7 +171,7 @@ namespace Content.IntegrationTests.Tests.Disposal
{ {
// Spawn the entities // Spawn the entities
var coordinates = testMap.GridCoords; var coordinates = testMap.GridCoords;
human = entityManager.SpawnEntity("HumanDummy", coordinates); human = entityManager.SpawnEntity("HumanDisposalDummy", coordinates);
wrench = entityManager.SpawnEntity("WrenchDummy", coordinates); wrench = entityManager.SpawnEntity("WrenchDummy", coordinates);
disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates); disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates);
disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy",

View File

@@ -12,10 +12,11 @@ namespace Content.IntegrationTests.Tests.DoAfter
[TestOf(typeof(DoAfterComponent))] [TestOf(typeof(DoAfterComponent))]
public sealed class DoAfterServerTest public sealed class DoAfterServerTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: Dummy name: DoAfterDummy
id: Dummy id: DoAfterDummy
components: components:
- type: DoAfter - type: DoAfter
"; ";
@@ -60,8 +61,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
await server.WaitIdleAsync(); await server.WaitIdleAsync();
@@ -75,7 +75,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var tickTime = 1.0f / timing.TickRate; var tickTime = 1.0f / timing.TickRate;
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace); var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace);
var args = new DoAfterArgs(mob, tickTime / 2, ev, null) { Broadcast = true }; var args = new DoAfterArgs(mob, tickTime / 2, ev, null) { Broadcast = true };
#pragma warning disable NUnit2045 // Interdependent assertions. #pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(doAfterSystem.TryStartDoAfter(args)); Assert.That(doAfterSystem.TryStartDoAfter(args));
@@ -94,8 +94,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
@@ -107,7 +106,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
{ {
var tickTime = 1.0f / timing.TickRate; var tickTime = 1.0f / timing.TickRate;
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace); var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace);
var args = new DoAfterArgs(mob, tickTime * 2, ev, null) { Broadcast = true }; var args = new DoAfterArgs(mob, tickTime * 2, ev, null) { Broadcast = true };
if (!doAfterSystem.TryStartDoAfter(args, out var id)) if (!doAfterSystem.TryStartDoAfter(args, out var id))

View File

@@ -13,10 +13,11 @@ namespace Content.IntegrationTests.Tests.Doors
[TestOf(typeof(AirlockComponent))] [TestOf(typeof(AirlockComponent))]
public sealed class AirlockTest public sealed class AirlockTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: PhysicsDummy name: AirlockPhysicsDummy
id: PhysicsDummy id: AirlockPhysicsDummy
components: components:
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Dynamic
@@ -54,8 +55,7 @@ namespace Content.IntegrationTests.Tests.Doors
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -117,8 +117,7 @@ namespace Content.IntegrationTests.Tests.Doors
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -130,24 +129,24 @@ namespace Content.IntegrationTests.Tests.Doors
var xformSystem = entityManager.System<SharedTransformSystem>(); var xformSystem = entityManager.System<SharedTransformSystem>();
PhysicsComponent physBody = null; PhysicsComponent physBody = null;
EntityUid physicsDummy = default; EntityUid AirlockPhysicsDummy = default;
EntityUid airlock = default; EntityUid airlock = default;
DoorComponent doorComponent = null; DoorComponent doorComponent = null;
var physicsDummyStartingX = -1; var AirlockPhysicsDummyStartingX = -1;
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var mapId = mapManager.CreateMap(); var mapId = mapManager.CreateMap();
var humanCoordinates = new MapCoordinates(new Vector2(physicsDummyStartingX, 0), mapId); var humanCoordinates = new MapCoordinates(new Vector2(AirlockPhysicsDummyStartingX, 0), mapId);
physicsDummy = entityManager.SpawnEntity("PhysicsDummy", humanCoordinates); AirlockPhysicsDummy = entityManager.SpawnEntity("AirlockPhysicsDummy", humanCoordinates);
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates(new Vector2(0, 0), mapId)); airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates(new Vector2(0, 0), mapId));
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(entityManager.TryGetComponent(physicsDummy, out physBody), Is.True); Assert.That(entityManager.TryGetComponent(AirlockPhysicsDummy, out physBody), Is.True);
Assert.That(entityManager.TryGetComponent(airlock, out doorComponent), Is.True); Assert.That(entityManager.TryGetComponent(airlock, out doorComponent), Is.True);
}); });
Assert.That(doorComponent.State, Is.EqualTo(DoorState.Closed)); Assert.That(doorComponent.State, Is.EqualTo(DoorState.Closed));
@@ -159,7 +158,7 @@ namespace Content.IntegrationTests.Tests.Doors
await server.WaitAssertion(() => Assert.That(physBody, Is.Not.EqualTo(null))); await server.WaitAssertion(() => Assert.That(physBody, Is.Not.EqualTo(null)));
await server.WaitPost(() => await server.WaitPost(() =>
{ {
physicsSystem.SetLinearVelocity(physicsDummy, new Vector2(0.5f, 0f), body: physBody); physicsSystem.SetLinearVelocity(AirlockPhysicsDummy, new Vector2(0.5f, 0f), body: physBody);
}); });
for (var i = 0; i < 240; i += 10) for (var i = 0; i < 240; i += 10)
@@ -178,12 +177,12 @@ namespace Content.IntegrationTests.Tests.Doors
// Sloth: Okay I'm sorry but I hate having to rewrite tests for every refactor // Sloth: Okay I'm sorry but I hate having to rewrite tests for every refactor
// If you see this yell at me in discord so I can continue to pretend this didn't happen. // If you see this yell at me in discord so I can continue to pretend this didn't happen.
// REMINDER THAT I STILL HAVE TO FIX THIS TEST EVERY OTHER PHYSICS PR // REMINDER THAT I STILL HAVE TO FIX THIS TEST EVERY OTHER PHYSICS PR
// Assert.That(physicsDummy.Transform.MapPosition.X, Is.GreaterThan(physicsDummyStartingX)); // Assert.That(AirlockPhysicsDummy.Transform.MapPosition.X, Is.GreaterThan(AirlockPhysicsDummyStartingX));
// Blocked by the airlock // Blocked by the airlock
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
Assert.That(Math.Abs(xformSystem.GetWorldPosition(physicsDummy).X - 1), Is.GreaterThan(0.01f)); Assert.That(Math.Abs(xformSystem.GetWorldPosition(AirlockPhysicsDummy).X - 1), Is.GreaterThan(0.01f));
}); });
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }

View File

@@ -21,7 +21,7 @@ namespace Content.IntegrationTests.Tests
{ {
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.NoSpawn || proto.Abstract || !proto.Components.ContainsKey("Sprite")) if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto) || !proto.Components.ContainsKey("Sprite"))
continue; continue;
Assert.DoesNotThrow(() => Assert.DoesNotThrow(() =>

View File

@@ -34,6 +34,7 @@ namespace Content.IntegrationTests.Tests
var protoIds = prototypeMan var protoIds = prototypeMan
.EnumeratePrototypes<EntityPrototype>() .EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract) .Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise. .Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Select(p => p.ID) .Select(p => p.ID)
.ToList(); .ToList();
@@ -90,6 +91,7 @@ namespace Content.IntegrationTests.Tests
var protoIds = prototypeMan var protoIds = prototypeMan
.EnumeratePrototypes<EntityPrototype>() .EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract) .Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise. .Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Select(p => p.ID) .Select(p => p.ID)
.ToList(); .ToList();
@@ -146,6 +148,7 @@ namespace Content.IntegrationTests.Tests
var protoIds = prototypeMan var protoIds = prototypeMan
.EnumeratePrototypes<EntityPrototype>() .EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract) .Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise. .Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Select(p => p.ID) .Select(p => p.ID)
.ToList(); .ToList();

View File

@@ -16,10 +16,11 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
[TestOf(typeof(HandcuffComponent))] [TestOf(typeof(HandcuffComponent))]
public sealed class HandCuffTest public sealed class HandCuffTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanDummy name: HumanHandcuffDummy
id: HumanDummy id: HumanHandcuffDummy
components: components:
- type: Cuffable - type: Cuffable
- type: Hands - type: Hands
@@ -38,8 +39,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -64,8 +64,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
var xformQuery = entityManager.GetEntityQuery<TransformComponent>(); var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
// Spawn the entities // Spawn the entities
human = entityManager.SpawnEntity("HumanDummy", coordinates); human = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
otherHuman = entityManager.SpawnEntity("HumanDummy", coordinates); otherHuman = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates); cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates); secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);

View File

@@ -9,18 +9,19 @@ namespace Content.IntegrationTests.Tests.Gravity
[TestOf(typeof(GravityGeneratorComponent))] [TestOf(typeof(GravityGeneratorComponent))]
public sealed class WeightlessStatusTests public sealed class WeightlessStatusTests
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanDummy name: HumanWeightlessDummy
id: HumanDummy id: HumanWeightlessDummy
components: components:
- type: Alerts - type: Alerts
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Dynamic
- type: entity - type: entity
name: GravityGeneratorDummy name: WeightlessGravityGeneratorDummy
id: GravityGeneratorDummy id: WeightlessGravityGeneratorDummy
components: components:
- type: GravityGenerator - type: GravityGenerator
chargeRate: 1000000000 # Set this really high so it discharges in a single tick. chargeRate: 1000000000 # Set this really high so it discharges in a single tick.
@@ -34,8 +35,7 @@ namespace Content.IntegrationTests.Tests.Gravity
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -48,7 +48,7 @@ namespace Content.IntegrationTests.Tests.Gravity
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
human = entityManager.SpawnEntity("HumanDummy", testMap.GridCoords); human = entityManager.SpawnEntity("HumanWeightlessDummy", testMap.GridCoords);
Assert.That(entityManager.TryGetComponent(human, out AlertsComponent alerts)); Assert.That(entityManager.TryGetComponent(human, out AlertsComponent alerts));
}); });
@@ -61,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Gravity
// No gravity without a gravity generator // No gravity without a gravity generator
Assert.That(alertsSystem.IsShowingAlert(human, AlertType.Weightless)); Assert.That(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
generatorUid = entityManager.SpawnEntity("GravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates); generatorUid = entityManager.SpawnEntity("WeightlessGravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
}); });
// Let WeightlessSystem and GravitySystem tick // Let WeightlessSystem and GravitySystem tick

View File

@@ -15,10 +15,11 @@ namespace Content.IntegrationTests.Tests
[TestOf(typeof(GravityGeneratorComponent))] [TestOf(typeof(GravityGeneratorComponent))]
public sealed class GravityGridTest public sealed class GravityGridTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: GravityGeneratorDummy name: GridGravityGeneratorDummy
id: GravityGeneratorDummy id: GridGravityGeneratorDummy
components: components:
- type: GravityGenerator - type: GravityGenerator
chargeRate: 1000000000 # Set this really high so it discharges in a single tick. chargeRate: 1000000000 # Set this really high so it discharges in a single tick.
@@ -31,8 +32,7 @@ namespace Content.IntegrationTests.Tests
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -56,7 +56,7 @@ namespace Content.IntegrationTests.Tests
grid1Entity = grid1.Owner; grid1Entity = grid1.Owner;
grid2Entity = grid2.Owner; grid2Entity = grid2.Owner;
generator = entityMan.SpawnEntity("GravityGeneratorDummy", grid2.ToCoordinates()); generator = entityMan.SpawnEntity("GridGravityGeneratorDummy", grid2.ToCoordinates());
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(entityMan.HasComponent<GravityGeneratorComponent>(generator)); Assert.That(entityMan.HasComponent<GravityGeneratorComponent>(generator));

View File

@@ -9,10 +9,11 @@ namespace Content.IntegrationTests.Tests
[TestFixture] [TestFixture]
public sealed class HumanInventoryUniformSlotsTest public sealed class HumanInventoryUniformSlotsTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanDummy name: HumanUniformDummy
id: HumanDummy id: HumanUniformDummy
components: components:
- type: Inventory - type: Inventory
- type: ContainerContainer - type: ContainerContainer
@@ -54,7 +55,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task Test() public async Task Test()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker); var testMap = await PoolManager.CreateTestMap(pairTracker);
var coordinates = testMap.GridCoords; var coordinates = testMap.GridCoords;
@@ -71,7 +72,7 @@ namespace Content.IntegrationTests.Tests
{ {
invSystem = entityMan.System<InventorySystem>(); invSystem = entityMan.System<InventorySystem>();
human = entityMan.SpawnEntity("HumanDummy", coordinates); human = entityMan.SpawnEntity("HumanUniformDummy", coordinates);
uniform = entityMan.SpawnEntity("UniformDummy", coordinates); uniform = entityMan.SpawnEntity("UniformDummy", coordinates);
idCard = entityMan.SpawnEntity("IDCardDummy", coordinates); idCard = entityMan.SpawnEntity("IDCardDummy", coordinates);
pocketItem = entityMan.SpawnEntity("FlashlightDummy", coordinates); pocketItem = entityMan.SpawnEntity("FlashlightDummy", coordinates);

View File

@@ -17,6 +17,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
[TestOf(typeof(InteractionSystem))] [TestOf(typeof(InteractionSystem))]
public sealed class InteractionSystemTests public sealed class InteractionSystemTests
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: DummyDebugWall id: DummyDebugWall
@@ -40,8 +41,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -114,8 +114,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -120,7 +120,8 @@ public abstract partial class InteractionTest
// Simple mob that has one hand and can perform misc interactions. // Simple mob that has one hand and can perform misc interactions.
public const string TestPrototypes = @" [TestPrototypes]
private const string TestPrototypes = @"
- type: entity - type: entity
id: InteractionTestMob id: InteractionTestMob
components: components:
@@ -139,7 +140,7 @@ public abstract partial class InteractionTest
[SetUp] [SetUp]
public virtual async Task Setup() public virtual async Task Setup()
{ {
PairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = TestPrototypes }); PairTracker = await PoolManager.GetServerClient();
// server dependencies // server dependencies
SEntMan = Server.ResolveDependency<IEntityManager>(); SEntMan = Server.ResolveDependency<IEntityManager>();

View File

@@ -9,6 +9,7 @@ namespace Content.IntegrationTests.Tests
[TestFixture] [TestFixture]
public sealed class InventoryHelpersTest public sealed class InventoryHelpersTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: InventoryStunnableDummy name: InventoryStunnableDummy
@@ -40,7 +41,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task SpawnItemInSlotTest() public async Task SpawnItemInSlotTest()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var sEntities = server.ResolveDependency<IEntityManager>(); var sEntities = server.ResolveDependency<IEntityManager>();

View File

@@ -38,7 +38,10 @@ public sealed class MachineBoardTest
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID))) foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !_ignoredPrototypes.Contains(p.ID)))
{ {
if (!p.TryGetComponent<MachineBoardComponent>(out var mbc)) if (!p.TryGetComponent<MachineBoardComponent>(out var mbc))
continue; continue;
@@ -74,7 +77,10 @@ public sealed class MachineBoardTest
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID))) foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract)
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
.Where(p => !_ignoredPrototypes.Contains(p.ID)))
{ {
if (!p.TryGetComponent<ComputerBoardComponent>(out var cbc)) if (!p.TryGetComponent<ComputerBoardComponent>(out var cbc))
continue; continue;

View File

@@ -65,7 +65,7 @@ public sealed class MaterialArbitrageTest
Dictionary<string, ConstructionComponent> constructionRecipes = new(); Dictionary<string, ConstructionComponent> constructionRecipes = new();
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.NoSpawn || proto.Abstract) if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
continue; continue;
if (!proto.Components.TryGetValue(constructionName, out var destructible)) if (!proto.Components.TryGetValue(constructionName, out var destructible))
@@ -125,7 +125,7 @@ public sealed class MaterialArbitrageTest
// Here we get the set of entities/materials spawned when destroying an entity. // Here we get the set of entities/materials spawned when destroying an entity.
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.NoSpawn || proto.Abstract) if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
continue; continue;
if (!proto.Components.TryGetValue(destructibleName, out var destructible)) if (!proto.Components.TryGetValue(destructibleName, out var destructible))
@@ -290,7 +290,7 @@ public sealed class MaterialArbitrageTest
Dictionary<string, PhysicalCompositionComponent> physicalCompositions = new(); Dictionary<string, PhysicalCompositionComponent> physicalCompositions = new();
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.NoSpawn || proto.Abstract) if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
continue; continue;
if (!proto.Components.TryGetValue(compositionName, out var composition)) if (!proto.Components.TryGetValue(compositionName, out var composition))

View File

@@ -13,6 +13,7 @@ namespace Content.IntegrationTests.Tests.Minds;
[TestFixture] [TestFixture]
public sealed class GhostRoleTests public sealed class GhostRoleTests
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: GhostRoleTestEntity id: GhostRoleTestEntity
@@ -29,7 +30,7 @@ public sealed class GhostRoleTests
[Test] [Test]
public async Task TakeRoleAndReturn() public async Task TakeRoleAndReturn()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient();
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var client = pairTracker.Pair.Client; var client = pairTracker.Pair.Client;

View File

@@ -24,6 +24,7 @@ namespace Content.IntegrationTests.Tests.Minds;
[TestFixture] [TestFixture]
public sealed partial class MindTests public sealed partial class MindTests
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: MindTestEntityDamageable id: MindTestEntityDamageable
@@ -109,7 +110,7 @@ public sealed partial class MindTests
[Test] [Test]
public async Task TestEntityDeadWhenGibbed() public async Task TestEntityDeadWhenGibbed()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>(); var entMan = server.ResolveDependency<IServerEntityManager>();

View File

@@ -42,6 +42,26 @@ namespace Content.IntegrationTests.Tests
"/Maps/infiltrator.yml", "/Maps/infiltrator.yml",
}; };
private static readonly string[] GameMaps =
{
"Dev",
"Fland",
"Meta",
"Packed",
"Aspid",
"Cluster",
"Omega",
"Bagel",
"Origin",
"CentComm",
"Box",
"Barratry",
"Saltern",
"Core",
"Marathon",
"Kettle"
};
/// <summary> /// <summary>
/// Asserts that specific files have been saved as grids and not maps. /// Asserts that specific files have been saved as grids and not maps.
/// </summary> /// </summary>
@@ -128,53 +148,7 @@ namespace Content.IntegrationTests.Tests
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }
private static string[] GetGameMapNames() [Test, TestCaseSource(nameof(GameMaps))]
{
Task<string[]> task;
using (ExecutionContext.SuppressFlow())
{
task = Task.Run(static async () =>
{
await Task.Yield();
await using var pairTracker = await PoolManager.GetServerClient(
new PoolSettings
{
Disconnected = true,
TestName = $"{nameof(PostMapInitTest)}.{nameof(GetGameMapNames)}"
}
);
var server = pairTracker.Pair.Server;
var protoManager = server.ResolveDependency<IPrototypeManager>();
var maps = protoManager.EnumeratePrototypes<GameMapPrototype>().ToList();
var mapNames = new List<string>();
var naughty = new HashSet<string>()
{
PoolManager.TestMap,
"Infiltrator",
"Pirate",
};
foreach (var map in maps)
{
// AAAAAAAAAA
// Why are they stations!
if (naughty.Contains(map.ID))
continue;
mapNames.Add(map.ID);
}
await pairTracker.CleanReturnAsync();
return mapNames.ToArray();
});
Task.WaitAny(task);
}
return task.GetAwaiter().GetResult();
}
[Test, TestCaseSource(nameof(GetGameMapNames))]
public async Task GameMapsLoadableTest(string mapProto) public async Task GameMapsLoadableTest(string mapProto)
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
@@ -306,86 +280,89 @@ namespace Content.IntegrationTests.Tests
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }
/// <summary> [Test]
/// Get the non-game map maps. public async Task AllMapsTested()
/// </summary>
private static string[] GetMaps()
{ {
Task<string[]> task; await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings {NoClient = true});
using (ExecutionContext.SuppressFlow()) var server = pairTracker.Pair.Server;
{ var protoMan = server.ResolveDependency<IPrototypeManager>();
task = Task.Run(static async () =>
{
await Task.Yield();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { Disconnected = true });
var server = pairTracker.Pair.Server;
var resourceManager = server.ResolveDependency<IResourceManager>();
var protoManager = server.ResolveDependency<IPrototypeManager>();
var gameMaps = protoManager.EnumeratePrototypes<GameMapPrototype>().Select(o => o.MapPath).ToHashSet(); var gameMaps = protoMan.EnumeratePrototypes<GameMapPrototype>()
.Where(x => !pairTracker.Pair.IsTestPrototype(x))
.Select(x => x.ID)
.ToHashSet();
var mapFolder = new ResPath("/Maps"); Assert.That(gameMaps.Remove(PoolManager.TestMap));
var maps = resourceManager
.ContentFindFiles(mapFolder)
.Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".", StringComparison.Ordinal))
.ToArray();
var mapNames = new List<string>();
foreach (var map in maps)
{
var rootedPath = map.ToRootedPath();
// ReSharper disable once RedundantLogicalConditionalExpressionOperand CollectionAssert.AreEquivalent(GameMaps.ToHashSet(), gameMaps, "Game map prototype missing from test cases.");
if (SkipTestMaps && rootedPath.ToString().StartsWith(TestMapsPath, StringComparison.Ordinal) ||
gameMaps.Contains(map))
{
continue;
}
mapNames.Add(rootedPath.ToString());
}
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
return mapNames.ToArray();
});
Task.WaitAny(task);
}
return task.GetAwaiter().GetResult();
} }
[Test, TestCaseSource(nameof(GetMaps))] [Test]
public async Task MapsLoadableTest(string mapName) public async Task NonGameMapsLoadableTest()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>(); var mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var resourceManager = server.ResolveDependency<IResourceManager>();
var protoManager = server.ResolveDependency<IPrototypeManager>();
var cfg = server.ResolveDependency<IConfigurationManager>(); var cfg = server.ResolveDependency<IConfigurationManager>();
Assert.That(cfg.GetCVar(CCVars.GridFill), Is.False); Assert.That(cfg.GetCVar(CCVars.GridFill), Is.False);
var gameMaps = protoManager.EnumeratePrototypes<GameMapPrototype>().Select(o => o.MapPath).ToHashSet();
var mapFolder = new ResPath("/Maps");
var maps = resourceManager
.ContentFindFiles(mapFolder)
.Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".", StringComparison.Ordinal))
.ToArray();
var mapNames = new List<string>();
foreach (var map in maps)
{
if (gameMaps.Contains(map))
continue;
var rootedPath = map.ToRootedPath();
if (SkipTestMaps && rootedPath.ToString().StartsWith(TestMapsPath, StringComparison.Ordinal))
{
continue;
}
mapNames.Add(rootedPath.ToString());
}
await server.WaitPost(() => await server.WaitPost(() =>
{ {
var mapId = mapManager.CreateMap(); Assert.Multiple(() =>
try
{ {
Assert.That(mapLoader.TryLoad(mapId, mapName, out _)); foreach (var mapName in mapNames)
} {
catch (Exception ex) var mapId = mapManager.CreateMap();
{ try
throw new Exception($"Failed to load map {mapName}", ex); {
} Assert.That(mapLoader.TryLoad(mapId, mapName, out _));
}
catch (Exception ex)
{
throw new Exception($"Failed to load map {mapName}", ex);
}
try try
{ {
mapManager.DeleteMap(mapId); mapManager.DeleteMap(mapId);
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception($"Failed to delete map {mapName}", ex); throw new Exception($"Failed to delete map {mapName}", ex);
} }
}
});
}); });
await server.WaitRunTicks(1);
await server.WaitRunTicks(1);
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();
} }
} }

View File

@@ -16,6 +16,7 @@ namespace Content.IntegrationTests.Tests.Power
[TestFixture] [TestFixture]
public sealed class PowerTest public sealed class PowerTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
id: GeneratorDummy id: GeneratorDummy
@@ -163,8 +164,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -228,8 +228,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -289,8 +288,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -380,8 +378,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -483,7 +480,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
// checks that batteries and supplies properly ramp down if the load is disconnected/disabled. // checks that batteries and supplies properly ramp down if the load is disconnected/disabled.
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
@@ -581,8 +578,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -641,8 +637,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -722,8 +717,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -803,8 +797,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -901,7 +894,7 @@ namespace Content.IntegrationTests.Tests.Power
[Test] [Test]
public async Task TestSupplyPrioritized() public async Task TestSupplyPrioritized()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
@@ -1001,8 +994,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -1092,8 +1084,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -1180,8 +1171,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -1249,8 +1239,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
@@ -1308,8 +1297,7 @@ namespace Content.IntegrationTests.Tests.Power
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();

View File

@@ -81,6 +81,9 @@ public sealed class PrototypeSaveTest
if (prototype.Abstract) if (prototype.Abstract)
continue; continue;
if (pairTracker.Pair.IsTestPrototype(prototype))
continue;
// Yea this test just doesn't work with this, it parents a grid to another grid and causes game logic to explode. // Yea this test just doesn't work with this, it parents a grid to another grid and causes game logic to explode.
if (prototype.Components.ContainsKey("MapGrid")) if (prototype.Components.ContainsKey("MapGrid"))
continue; continue;

View File

@@ -62,6 +62,9 @@ public sealed class ResearchTest
if (proto.Abstract) if (proto.Abstract)
continue; continue;
if (pairTracker.Pair.IsTestPrototype(proto))
continue;
if (!proto.TryGetComponent<LatheComponent>(out var lathe)) if (!proto.TryGetComponent<LatheComponent>(out var lathe))
continue; continue;
allLathes.Add(lathe); allLathes.Add(lathe);

View File

@@ -18,9 +18,10 @@ namespace Content.IntegrationTests.Tests.Station;
[TestOf(typeof(StationJobsSystem))] [TestOf(typeof(StationJobsSystem))]
public sealed class StationJobsTest public sealed class StationJobsTest
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: playTimeTracker - type: playTimeTracker
id: Dummy id: PlayTimeDummy
- type: gameMap - type: gameMap
id: FooStation id: FooStation
@@ -43,26 +44,26 @@ public sealed class StationJobsTest
- type: job - type: job
id: TAssistant id: TAssistant
playTimeTracker: Dummy playTimeTracker: PlayTimeDummy
- type: job - type: job
id: TMime id: TMime
weight: 20 weight: 20
playTimeTracker: Dummy playTimeTracker: PlayTimeDummy
- type: job - type: job
id: TClown id: TClown
weight: -10 weight: -10
playTimeTracker: Dummy playTimeTracker: PlayTimeDummy
- type: job - type: job
id: TCaptain id: TCaptain
weight: 10 weight: 10
playTimeTracker: Dummy playTimeTracker: PlayTimeDummy
- type: job - type: job
id: TChaplain id: TChaplain
playTimeTracker: Dummy playTimeTracker: PlayTimeDummy
"; ";
private const int StationCount = 100; private const int StationCount = 100;
@@ -75,8 +76,7 @@ public sealed class StationJobsTest
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -153,8 +153,7 @@ public sealed class StationJobsTest
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
@@ -208,8 +207,7 @@ public sealed class StationJobsTest
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -15,14 +15,15 @@ namespace Content.IntegrationTests.Tests.Tag
private const string TagEntityId = "TagTestDummy"; private const string TagEntityId = "TagTestDummy";
// Register these three into the prototype manager // Register these three into the prototype manager
private const string StartingTag = "A"; private const string StartingTag = "StartingTagDummy";
private const string AddedTag = "EIOU"; private const string AddedTag = "AddedTagDummy";
private const string UnusedTag = "E"; private const string UnusedTag = "UnusedTagDummy";
// Do not register this one // Do not register this one
private const string UnregisteredTag = "AAAAAAAAA"; private const string UnregisteredTag = "AAAAAAAAA";
private static readonly string Prototypes = $@" [TestPrototypes]
private const string Prototypes = $@"
- type: Tag - type: Tag
id: {StartingTag} id: {StartingTag}
@@ -45,8 +46,7 @@ namespace Content.IntegrationTests.Tests.Tag
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -12,7 +12,8 @@ namespace Content.IntegrationTests.Tests.Utility
{ {
private const string BlockerDummyId = "BlockerDummy"; private const string BlockerDummyId = "BlockerDummy";
private static readonly string Prototypes = $@" [TestPrototypes]
private const string Prototypes = $@"
- type: entity - type: entity
id: {BlockerDummyId} id: {BlockerDummyId}
name: {BlockerDummyId} name: {BlockerDummyId}
@@ -33,8 +34,7 @@ namespace Content.IntegrationTests.Tests.Utility
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{ {
NoClient = true, NoClient = true
ExtraPrototypes = Prototypes
}); });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;

View File

@@ -12,11 +12,12 @@ namespace Content.IntegrationTests.Tests.Utility
private const string InvalidComponent = "Sprite"; private const string InvalidComponent = "Sprite";
private const string ValidComponent = "Physics"; private const string ValidComponent = "Physics";
private static readonly string Prototypes = $@" [TestPrototypes]
private const string Prototypes = $@"
- type: Tag - type: Tag
id: ValidTag id: WhitelistTestValidTag
- type: Tag - type: Tag
id: InvalidTag id: WhitelistTestInvalidTag
- type: entity - type: entity
id: WhitelistDummy id: WhitelistDummy
@@ -30,34 +31,34 @@ namespace Content.IntegrationTests.Tests.Utility
components: components:
- {ValidComponent} - {ValidComponent}
tags: tags:
- ValidTag - WhitelistTestValidTag
- type: entity - type: entity
id: InvalidComponentDummy id: InvalidComponentDummy
components: components:
- type: {InvalidComponent} - type: {InvalidComponent}
- type: entity - type: entity
id: InvalidTagDummy id: WhitelistTestInvalidTagDummy
components: components:
- type: Tag - type: Tag
tags: tags:
- InvalidTag - WhitelistTestInvalidTag
- type: entity - type: entity
id: ValidComponentDummy id: ValidComponentDummy
components: components:
- type: {ValidComponent} - type: {ValidComponent}
- type: entity - type: entity
id: ValidTagDummy id: WhitelistTestValidTagDummy
components: components:
- type: Tag - type: Tag
tags: tags:
- ValidTag"; - WhitelistTestValidTag";
[Test] [Test]
public async Task Test() public async Task Test()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker); var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -68,16 +69,16 @@ namespace Content.IntegrationTests.Tests.Utility
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var validComponent = sEntities.SpawnEntity("ValidComponentDummy", mapCoordinates); var validComponent = sEntities.SpawnEntity("ValidComponentDummy", mapCoordinates);
var validTag = sEntities.SpawnEntity("ValidTagDummy", mapCoordinates); var WhitelistTestValidTag = sEntities.SpawnEntity("WhitelistTestValidTagDummy", mapCoordinates);
var invalidComponent = sEntities.SpawnEntity("InvalidComponentDummy", mapCoordinates); var invalidComponent = sEntities.SpawnEntity("InvalidComponentDummy", mapCoordinates);
var invalidTag = sEntities.SpawnEntity("InvalidTagDummy", mapCoordinates); var WhitelistTestInvalidTag = sEntities.SpawnEntity("WhitelistTestInvalidTagDummy", mapCoordinates);
// Test instantiated on its own // Test instantiated on its own
var whitelistInst = new EntityWhitelist var whitelistInst = new EntityWhitelist
{ {
Components = new[] { $"{ValidComponent}" }, Components = new[] { $"{ValidComponent}" },
Tags = new() { "ValidTag" } Tags = new() { "WhitelistTestValidTag" }
}; };
whitelistInst.UpdateRegistrations(); whitelistInst.UpdateRegistrations();
Assert.That(whitelistInst, Is.Not.Null); Assert.That(whitelistInst, Is.Not.Null);
@@ -91,10 +92,10 @@ namespace Content.IntegrationTests.Tests.Utility
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(whitelistInst.IsValid(validComponent), Is.True); Assert.That(whitelistInst.IsValid(validComponent), Is.True);
Assert.That(whitelistInst.IsValid(validTag), Is.True); Assert.That(whitelistInst.IsValid(WhitelistTestValidTag), Is.True);
Assert.That(whitelistInst.IsValid(invalidComponent), Is.False); Assert.That(whitelistInst.IsValid(invalidComponent), Is.False);
Assert.That(whitelistInst.IsValid(invalidTag), Is.False); Assert.That(whitelistInst.IsValid(WhitelistTestInvalidTag), Is.False);
}); });
// Test from serialized // Test from serialized
@@ -111,10 +112,10 @@ namespace Content.IntegrationTests.Tests.Utility
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(whitelistSer.IsValid(validComponent), Is.True); Assert.That(whitelistSer.IsValid(validComponent), Is.True);
Assert.That(whitelistSer.IsValid(validTag), Is.True); Assert.That(whitelistSer.IsValid(WhitelistTestValidTag), Is.True);
Assert.That(whitelistSer.IsValid(invalidComponent), Is.False); Assert.That(whitelistSer.IsValid(invalidComponent), Is.False);
Assert.That(whitelistSer.IsValid(invalidTag), Is.False); Assert.That(whitelistSer.IsValid(WhitelistTestInvalidTag), Is.False);
}); });
}); });
await pairTracker.CleanReturnAsync(); await pairTracker.CleanReturnAsync();

View File

@@ -11,6 +11,7 @@ using Content.Shared.Damage.Prototypes;
using Content.Shared.VendingMachines; using Content.Shared.VendingMachines;
using Content.Shared.Wires; using Content.Shared.Wires;
using Content.Server.Wires; using Content.Server.Wires;
using Content.Shared.Prototypes;
namespace Content.IntegrationTests.Tests namespace Content.IntegrationTests.Tests
{ {
@@ -19,10 +20,11 @@ namespace Content.IntegrationTests.Tests
[TestOf(typeof(VendingMachineSystem))] [TestOf(typeof(VendingMachineSystem))]
public sealed class VendingMachineRestockTest : EntitySystem public sealed class VendingMachineRestockTest : EntitySystem
{ {
[TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: entity - type: entity
name: HumanDummy name: HumanVendingDummy
id: HumanDummy id: HumanVendingDummy
components: components:
- type: Hands - type: Hands
- type: Body - type: Body
@@ -117,8 +119,9 @@ namespace Content.IntegrationTests.Tests
// Collect all the prototypes with restock components. // Collect all the prototypes with restock components.
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.Abstract || if (proto.Abstract
!proto.TryGetComponent<VendingMachineRestockComponent>(out var restock)) || pairTracker.Pair.IsTestPrototype(proto)
|| !proto.HasComponent<VendingMachineRestockComponent>())
{ {
continue; continue;
} }
@@ -173,7 +176,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestCompleteRestockProcess() public async Task TestCompleteRestockProcess()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
await server.WaitIdleAsync(); await server.WaitIdleAsync();
@@ -197,7 +200,7 @@ namespace Content.IntegrationTests.Tests
var coordinates = testMap.GridCoords; var coordinates = testMap.GridCoords;
// Spawn the entities. // Spawn the entities.
user = entityManager.SpawnEntity("HumanDummy", coordinates); user = entityManager.SpawnEntity("HumanVendingDummy", coordinates);
machine = entityManager.SpawnEntity("VendingMachineTest", coordinates); machine = entityManager.SpawnEntity("VendingMachineTest", coordinates);
packageRight = entityManager.SpawnEntity("TestRestockCorrect", coordinates); packageRight = entityManager.SpawnEntity("TestRestockCorrect", coordinates);
packageWrong = entityManager.SpawnEntity("TestRestockWrong", coordinates); packageWrong = entityManager.SpawnEntity("TestRestockWrong", coordinates);
@@ -259,7 +262,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestRestockBreaksOpen() public async Task TestRestockBreaksOpen()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
await server.WaitIdleAsync(); await server.WaitIdleAsync();
@@ -323,7 +326,7 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task TestRestockInventoryBounds() public async Task TestRestockInventoryBounds()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes }); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
await server.WaitIdleAsync(); await server.WaitIdleAsync();

View File

@@ -29,6 +29,7 @@ namespace Content.MapRenderer
if (!CommandLineArguments.TryParse(args, out var arguments)) if (!CommandLineArguments.TryParse(args, out var arguments))
return; return;
PoolManager.Startup(null);
if (arguments.Maps.Count == 0) if (arguments.Maps.Count == 0)
{ {
Console.WriteLine("Didn't specify any maps to paint! Loading the map list..."); Console.WriteLine("Didn't specify any maps to paint! Loading the map list...");
@@ -135,6 +136,7 @@ namespace Content.MapRenderer
} }
await Run(arguments); await Run(arguments);
PoolManager.Shutdown();
} }
private static async Task Run(CommandLineArguments arguments) private static async Task Run(CommandLineArguments arguments)

View File

@@ -15,6 +15,7 @@ namespace Content.YAMLLinter
{ {
private static async Task<int> Main(string[] _) private static async Task<int> Main(string[] _)
{ {
PoolManager.Startup(null);
var stopwatch = new Stopwatch(); var stopwatch = new Stopwatch();
stopwatch.Start(); stopwatch.Start();
@@ -42,6 +43,7 @@ namespace Content.YAMLLinter
} }
Console.WriteLine($"{count} errors found in {(int) stopwatch.Elapsed.TotalMilliseconds} ms."); Console.WriteLine($"{count} errors found in {(int) stopwatch.Elapsed.TotalMilliseconds} ms.");
PoolManager.Shutdown();
return -1; return -1;
} }