Integration test logging improvements (#3814)

This commit is contained in:
Pieter-Jan Briers
2023-03-05 22:52:31 +01:00
committed by GitHub
parent 674fc0d1c0
commit de00d2aca2
3 changed files with 13 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
@@ -245,6 +246,8 @@ namespace Robust.UnitTesting
private protected readonly ChannelReader<object> _fromInstanceReader;
private protected readonly ChannelWriter<object> _fromInstanceWriter;
private protected TextWriter _testOut;
private int _currentTicksId = 1;
private int _ackTicksId;
@@ -302,6 +305,7 @@ namespace Robust.UnitTesting
private protected IntegrationInstance(IntegrationOptions? options)
{
Options = options;
_testOut = TestContext.Out;
var toInstance = Channel.CreateUnbounded<object>(new UnboundedChannelOptions
{
@@ -659,7 +663,8 @@ namespace Robust.UnitTesting
});
server.ContentStart = Options?.ContentStart ?? false;
if (server.Start(serverOptions, () => new TestLogHandler(cfg, "SERVER")))
var logHandler = Options?.OverrideLogHandler ?? (() => new TestLogHandler(cfg, "SERVER", _testOut));
if (server.Start(serverOptions, logHandler))
{
throw new Exception("Server failed to start.");
}
@@ -840,7 +845,7 @@ namespace Robust.UnitTesting
client.ContentStart = Options?.ContentStart ?? false;
client.StartupSystemSplash(
clientOptions,
() => new TestLogHandler(cfg, "CLIENT"),
Options?.OverrideLogHandler ?? (() => new TestLogHandler(cfg, "CLIENT", _testOut)),
globalExceptionLog: false);
client.StartupContinue(GameController.DisplayMode.Headless);
@@ -986,6 +991,8 @@ namespace Robust.UnitTesting
public Dictionary<string, string> CVarOverrides { get; } = new();
public bool Asynchronous { get; set; } = true;
public bool? Pool { get; set; }
public Func<ILogHandler>? OverrideLogHandler { get; set; }
}
/// <summary>