Files
Chronos/tests/Chronos.Testing/ConsoleReporter.cs
T
Alby96andClaude Opus 5.5 f2b58522b9
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-23 12:45:18 +02:00

73 lines
3.3 KiB
C#

using System.Globalization;
namespace Chronos.Testing;
internal sealed class ConsoleReporter(bool verbose) : IDisposable
{
private readonly Lock _gate = new();
public void Report(TestResult r)
{
lock (_gate)
{
switch (r.Outcome)
{
case TestOutcome.Failed:
if (WorkflowRun)
Console.WriteLine($"::error title=Test failed::{Escape(r.Test.FullName)}: {Escape(r.Message ?? "failed")}");
Write(ConsoleColor.Red, "FAIL ");
Console.WriteLine($"{r.Test.FullName} ({Ms(r.Duration)})");
Console.WriteLine(" " + r.Message);
if (r.StackTrace is not null) Console.WriteLine(Indent(r.StackTrace));
if (r.Log.Length > 0) Console.WriteLine(Indent(r.Log));
break;
case TestOutcome.Skipped when verbose:
Write(ConsoleColor.Yellow, "SKIP ");
Console.WriteLine($"{r.Test.FullName} — {r.Message}");
break;
case TestOutcome.Passed when verbose:
Write(ConsoleColor.Green, "PASS ");
Console.WriteLine($"{r.Test.FullName} ({Ms(r.Duration)})");
if (r.Log.Length > 0) Console.WriteLine(Indent(r.Log));
break;
}
}
}
public void Summary(string suite, int passed, int failed, int skipped, TimeSpan elapsed, IReadOnlyList<TestResult> results)
{
lock (_gate)
{
Console.WriteLine();
var slowest = results.Where(r => r.Outcome == TestOutcome.Passed).OrderByDescending(r => r.Duration).Take(3).ToList();
if (verbose && slowest.Count > 0)
{
Console.WriteLine("Slowest:");
foreach (var r in slowest) Console.WriteLine($" {Ms(r.Duration),9} {r.Test.FullName}");
}
Write(failed > 0 ? ConsoleColor.Red : ConsoleColor.Green, failed > 0 ? "FAILED" : "PASSED");
Console.WriteLine($" {suite}: {passed} passed, {failed} failed, {skipped} skipped in {elapsed.TotalSeconds.ToString("F1", CultureInfo.InvariantCulture)} s");
}
}
public void Dispose() => Console.Out.Flush();
/// <summary>Running in Gitea Actions, which sets GITHUB_ACTIONS and keeps the GitHub-compatible workflow commands.</summary>
private static bool WorkflowRun { get; } = Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true";
/// <summary>Workflow-command escaping: % and line breaks become %25, %0D and %0A.</summary>
private static string Escape(string s) => s.Replace("%", "%25", StringComparison.Ordinal).Replace("\r", "%0D", StringComparison.Ordinal).Replace("\n", "%0A", StringComparison.Ordinal);
private static string Ms(TimeSpan t) => t.TotalMilliseconds.ToString("F0", CultureInfo.InvariantCulture) + " ms";
private static string Indent(string s) => string.Join(Environment.NewLine, s.TrimEnd().Split('\n').Select(l => " " + l.TrimEnd('\r')));
private static void Write(ConsoleColor color, string text)
{
var redirected = Console.IsOutputRedirected;
if (!redirected) Console.ForegroundColor = color;
Console.Write(text);
if (!redirected) Console.ResetColor();
}
}