feat(render): end-to-end self-test suite and Titano.Tools selftest

63 reusable checks (plan, export, encoder selection, codec round trips,
renders into every managed format decoded back, MP4 inspection when a
platform encoder is supplied, processing modules measured on rendered
frames, cancellation, failures, determinism, memory) shared by the CLI
and the desktop Settings page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 11:16:39 +00:00
1 parent 3780105f36
commit 2a9f93e414
6 files changed
+1242

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);
}
}
}
+1
View File
@@ -8,6 +8,7 @@ var commands = new ICommand[]
new XamlLintCommand(),
new PackageGuardCommand(),
new ChangelogCommand(),
new SelfTestCommand(),
};
if (args.Length == 0 || args[0] is "-h" or "--help" or "help")