merge: render plan, pipeline, managed encoders and self-test
# Conflicts: # src/Titano.Tools/Program.cs
This commit is contained in:
38 files changed
+6649
No files matched your search
@@ -0,0 +1,79 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Render.Diagnostics;
|
||||
|
||||
namespace Titano.Tools.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// <c>selftest [prefix…] [--filter prefix] [--list]</c>: the engine's end-to-end self-test (BRIEF §20.2, §20.4) with
|
||||
/// the managed encoders. Prints a PASS/FAIL table; exits 1 when a check fails, 2 when no check matched.
|
||||
/// </summary>
|
||||
internal sealed class SelfTestCommand : ICommand
|
||||
{
|
||||
public string Name => "selftest";
|
||||
public string Summary => "Render synthetic sequences end to end and verify the outputs";
|
||||
|
||||
public async Task<int> RunAsync(string[] args)
|
||||
{
|
||||
var a = new Args(args, "list");
|
||||
var filters = a.Positional.ToList();
|
||||
if (a.Get("filter") is { } filter) filters.Add(filter);
|
||||
if (a.Has("list"))
|
||||
{
|
||||
foreach (var check in SelfTest.Checks) Console.WriteLine($"{check.Id,-26} {check.Description}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
using var cts = new CancellationTokenSource();
|
||||
ConsoleCancelEventHandler cancel = (_, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
cts.Cancel();
|
||||
};
|
||||
Console.CancelKeyPress += cancel;
|
||||
// Expected failures (fault injection, render-node notices) are logged by the engine; the table says enough.
|
||||
var level = Log.MinimumLevel;
|
||||
Log.MinimumLevel = LogLevel.Error;
|
||||
try
|
||||
{
|
||||
var clock = Stopwatch.StartNew();
|
||||
Console.WriteLine($"{"RESULT",-6} {"CHECK",-26} {"TIME",8} DETAIL");
|
||||
var results = await SelfTest.RunAsync(new SelfTestOptions { Filters = filters }, new ConsoleRows(), cts.Token);
|
||||
var passed = results.Count(r => r.Outcome == SelfTestOutcome.Passed);
|
||||
var failed = results.Count(r => r.Outcome == SelfTestOutcome.Failed);
|
||||
var skipped = results.Count(r => r.Outcome == SelfTestOutcome.Skipped);
|
||||
Console.WriteLine(string.Create(CultureInfo.InvariantCulture,
|
||||
$"{(failed == 0 ? "PASSED" : "FAILED")} {results.Count} checks: {passed} passed, {failed} failed, {skipped} skipped in {clock.Elapsed.TotalSeconds:F1} s"));
|
||||
if (results.Count == 0) return 2;
|
||||
return failed == 0 ? 0 : 1;
|
||||
}
|
||||
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||
{
|
||||
Console.Error.WriteLine("Self-test cancelled.");
|
||||
return 2;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.MinimumLevel = level;
|
||||
Console.CancelKeyPress -= cancel;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Prints each result as soon as its check finishes.</summary>
|
||||
private sealed class ConsoleRows : IProgress<SelfTestResult>
|
||||
{
|
||||
public void Report(SelfTestResult r)
|
||||
{
|
||||
var label = r.Outcome switch
|
||||
{
|
||||
SelfTestOutcome.Passed => "PASS",
|
||||
SelfTestOutcome.Failed => "FAIL",
|
||||
_ => "SKIP",
|
||||
};
|
||||
var line = string.Create(CultureInfo.InvariantCulture, $"{label,-6} {r.Id,-26} {r.Elapsed.TotalMilliseconds,6:F0} ms {r.Detail}");
|
||||
if (r.Outcome == SelfTestOutcome.Failed) Console.Error.WriteLine(line);
|
||||
else Console.WriteLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ var commands = new ICommand[]
|
||||
new PackageGuardCommand(),
|
||||
new ChangelogCommand(),
|
||||
new PackInstallerCommand(),
|
||||
new SelfTestCommand(),
|
||||
};
|
||||
|
||||
if (args.Length == 0 || args[0] is "-h" or "--help" or "help")
|
||||
|
||||
Reference in new issue
Block a user