mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
* Add test pooling and global test setup * WIP test pooling changes * Make asynchronous tests the default again * Finish fixing tests, make test threads background threads * Un-pool tests with custom cvars * Fix not changing FailureLogLevel cvar on instance return * Fix error when overriding already overriden cvar * Don't pool some physics integration tests * Unpool engine tests, the technology just isn't there yet * Remove explicit Pool = false from physics tests * Change default pooling setting to false * Didn't need this anyway * Remove ConfigurationManager.ResetOverrides * Bring back enum cvar override parsing * Make integrationInstances name clearer > notPooledInstaces Make clients ready and servers ready internal * Add logging test instances * Give more info on ran tests * Show total clients and servers in test output * Wipe LayerMap on SpriteComponent.AfterDeserialize * Fix server not properly kicking clients * Rider shut * Make all test metrics report totals * Format tests ran better * Replace Console.WriteLine with TestContext.Out.WriteLine * Fix two server test pooling info prints using total clients instead of total servers Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Log;
|
|
using Serilog.Events;
|
|
|
|
namespace Robust.UnitTesting
|
|
{
|
|
public sealed class TestLogHandler : ILogHandler, IDisposable
|
|
{
|
|
private readonly string? _prefix;
|
|
private readonly TextWriter _writer;
|
|
private readonly Stopwatch _sw = Stopwatch.StartNew();
|
|
|
|
public TestLogHandler(IConfigurationManager cfg, string? prefix = null)
|
|
{
|
|
cfg.OnValueChanged(RTCVars.FailureLogLevel, value => FailureLevel = value, true);
|
|
|
|
_prefix = prefix;
|
|
_writer = TestContext.Out;
|
|
_writer.WriteLine($"{GetPrefix()}Started {DateTime.Now:o}");
|
|
}
|
|
|
|
private LogLevel? FailureLevel { get; set; }
|
|
|
|
public void Dispose()
|
|
{
|
|
_writer.Dispose();
|
|
}
|
|
|
|
public void Log(string sawmillName, LogEvent message)
|
|
{
|
|
var level = message.Level.ToRobust();
|
|
var name = LogMessage.LogLevelToName(level);
|
|
var seconds = _sw.ElapsedMilliseconds / 1000d;
|
|
var rendered = message.RenderMessage();
|
|
var line = $"{GetPrefix()}{seconds:F3}s [{name}] {sawmillName}: {rendered}";
|
|
_writer.WriteLine(line);
|
|
|
|
if (FailureLevel == null || level < FailureLevel)
|
|
return;
|
|
|
|
_writer.Flush();
|
|
Assert.Fail($"{line} Exception: {message.Exception}");
|
|
}
|
|
|
|
private string GetPrefix()
|
|
{
|
|
return _prefix != null ? $"{_prefix}: " : "";
|
|
}
|
|
}
|
|
}
|