Files
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

132 lines
8.4 KiB
C#

using System.Xml.Linq;
using Chronos.Testing;
using Chronos.Tools.Commands;
namespace Chronos.Tools.Tests;
/// <summary><c>i18n check</c>: English texts that count something need plural forms (BRIEF §16), and every error code
/// of the server has its message, whose key is built at run time.</summary>
public sealed class I18nCommandTests(TestContext context)
{
[Test]
public void ANumberInFrontOfACountedNounNeedsPluralForms()
{
Assert.Equal("frames", I18nCommand.CountedNoun("Advisor.Finding.BlackFrames", "{0} frames are black (lens cap or missed exposure)."));
Assert.Equal("gaps", I18nCommand.CountedNoun("Advisor.Reason.Timing.SparseGaps", "{0} short gaps, but motion is unmeasured or fast."));
Assert.Equal("changes", I18nCommand.CountedNoun("Advisor.Finding.StepsNotReceived", "{0} logged exposure changes never reached the pixels."));
Assert.Equal("times", I18nCommand.CountedNoun("Advisor.Finding.LensChanged", "The lens changes {0} times."));
Assert.Equal("sequences", I18nCommand.CountedNoun("Errors.Analysis.Failed", "{0} of {1} sequences could not be analysed; see the job log."));
Assert.Equal("jobs", I18nCommand.CountedNoun("Shell.JobBar.Ready", "Ready · {0:N0} jobs queued"));
Assert.Equal("cores", I18nCommand.CountedNoun("Settings.Rendering.Cores", "of {0} logical cores"));
}
[Test]
public void PluralFormsBoundsLabelsAndUnitsCountNothing()
{
Assert.Null(I18nCommand.CountedNoun("Advisor.Finding.BlackFrames.other", "{0} frames are black (lens cap or missed exposure)."));
Assert.Null(I18nCommand.CountedNoun("Advisor.Finding.BlackFrames.one", "{0} frame is black (lens cap or missed exposure)."));
Assert.Null(I18nCommand.CountedNoun("Server.Error.WeakPassword", "Use at least {0} characters."));
Assert.Null(I18nCommand.CountedNoun("Library.Views.Error.Long", "At most {0} characters, no control characters."));
Assert.Null(I18nCommand.CountedNoun("Archive.Retag.Invalid", "Each tag has 1 to {0} characters."));
Assert.Null(I18nCommand.CountedNoun("Archive.Log.ScanDone", "Folders: {0}, indexed: {1}, adopted: {2}, removed: {3}"));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Window.Period.other", "Flicker repeats every {0} frames: a {1}-frame window averages four cycles."));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Timing.Regular", "Steady {0} s interval (jitter {1} s): each photo becomes one video frame."));
Assert.Null(I18nCommand.CountedNoun("Tooltips.Editor.Remote", "Changes are saved on {0} and analyses and renders run there"));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Transition.Single", "A single exposure step: a {0}-frame transition keeps the change gentle."));
}
[Test]
public void ATallyOfParticiplesNeedsLabels()
{
// Italian reads "1 copiate · 1 non riuscite": the participle agrees with the number in front of it.
Assert.Equal("copied", I18nCommand.CountedTally("Import.Result.Partial", "{0} copied · {1} failed"));
Assert.Equal("missing", I18nCommand.CountedTally("Archive.Health.Damaged", "{0} missing · {1} damaged"));
Assert.Equal("made", I18nCommand.CountedTally("Archive.Log.ImagesDone", "{0}: {1} made, {2} reused, {3} unreadable"));
Assert.Equal("copied", I18nCommand.CountedTally("Archive.Log.ImportDone", "{0:N0} copied, {1:N0} skipped, {2:N0} failed."));
}
[Test]
public void LabelsNamesAndSizesAreNoTally()
{
Assert.Null(I18nCommand.CountedTally("Import.Result.Partial", "Copied: {0} · failed: {1}"));
Assert.Null(I18nCommand.CountedTally("Archive.Log.ImagesDone", "{0}: made {1}, reused {2}, unreadable {3}"));
Assert.Null(I18nCommand.CountedTally("Archive.Log.ScanDone", "Folders: {0}, indexed: {1}, adopted: {2}, removed: {3}"));
// A single participle after a placeholder is as often a name or a size as a count.
Assert.Null(I18nCommand.CountedTally("Export.Log.Failed", "{0} failed: {1}"));
Assert.Null(I18nCommand.CountedTally("Library.Queued", "{0} queued · {1}"));
Assert.Null(I18nCommand.CountedTally("Import.Plan.SpaceMissing", "{0} missing"));
Assert.Null(I18nCommand.CountedTally("Settings.Storage.Usage", "{0} used · {1} free"));
Assert.Null(I18nCommand.CountedTally("Import.Result.Skipped.other", "{0:N0} copied, {1:N0} skipped"));
}
[Test]
public void PruneRemovesOnlyTheKeysEnglishNoLongerHas()
{
var dir = context.CreateTempDirectory();
void Write(string culture, string file, params (string Key, string Value)[] entries)
{
Directory.CreateDirectory(Path.Combine(dir, culture));
var data = string.Concat(entries.Select(e => $" <data name=\"{e.Key}\" xml:space=\"preserve\"><value>{e.Value}</value></data>\n"));
File.WriteAllText(Path.Combine(dir, culture, file), $"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n{data}</root>\n");
}
Write("en", "Jobs.resx", ("Jobs.Kind.Render", "Render"), ("Jobs.Parallelism.one", "{0} photo at once"), ("Jobs.Parallelism.other", "{0} photos at once"));
Write("it", "Jobs.it.resx", ("Jobs.Kind.Render", "Render"), ("Jobs.Workers", "Processi {0} / {1}"), ("Jobs.Parallelism.one", "{0} foto alla volta"));
// Polish adds plural forms English has not: they stay.
Write("pl", "Jobs.pl.resx", ("Jobs.Parallelism.few", "{0} zdjęcia naraz"), ("Jobs.Parallelism.many", "{0} zdjęć naraz"));
var untouched = File.ReadAllText(Path.Combine(dir, "pl", "Jobs.pl.resx"));
Assert.Equal(1, I18nCommand.PruneOrphans(dir, I18nCommand.Catalog.Load(dir)));
var italian = I18nCommand.Catalog.Load(dir).Cultures["it"];
Assert.SequenceEqual(["Jobs.Kind.Render", "Jobs.Parallelism.one"], italian.Keys.Order(StringComparer.Ordinal));
Assert.Equal("{0} foto alla volta", italian["Jobs.Parallelism.one"].Value);
Assert.Equal(untouched, File.ReadAllText(Path.Combine(dir, "pl", "Jobs.pl.resx")));
Assert.Equal(3, I18nCommand.Catalog.Load(dir).Cultures["en"].Count);
Assert.Equal(0, I18nCommand.PruneOrphans(dir, I18nCommand.Catalog.Load(dir)));
}
[Test]
public void ErrorCodesAreTheLiteralsPassedToTheServerErrorHelpers()
{
const string source = """
if (bad) return ApiErrors.BadRequest(context, "invalid_filter", "status");
return known.SequenceId == sequenceId
? new StartUploadResponse(null, options.ChunkSizeBytes, [], AlreadyExists: true, null)
: Outcome<StartUploadResponse>.Fail(409, "render_exists");
return Fail<ChunkReceived>(400, "chunk_size", expected.ToString(CultureInfo.InvariantCulture));
DeleteBlock.Offline => ApiErrors.Result(context, StatusCodes.Status503ServiceUnavailable,
"archive_offline"),
return TooMany(context, "rate_limited", wait);
return ApiErrors.NotFound(context, "sequence");
return ApiErrors.BadRequest(context, code, setting, setting);
await FailAsync(upload, "not_a_code");
""";
Assert.SequenceEqual(["invalid_filter", "render_exists", "chunk_size", "archive_offline", "rate_limited"], I18nCommand.ErrorCodes(source).ToList());
}
[Test]
public void AnErrorCodeNamesItsMessageKeyLikeTheServer()
{
Assert.Equal("Server.Error.RenderExists", I18nCommand.ErrorKey("render_exists"));
Assert.Equal("Server.Error.Forbidden", I18nCommand.ErrorKey("forbidden"));
Assert.Equal("Server.Error.Http413", I18nCommand.ErrorKey("http_413"));
}
[Test]
public void EveryErrorCodeOfTheServerHasAnEnglishMessage()
{
var root = Args.RepoRoot();
var keys = XDocument.Load(Path.Combine(root, "i18n", "en", "Server.resx")).Root!.Elements("data")
.Select(d => (string)d.Attribute("name")!).ToHashSet(StringComparer.Ordinal);
var missing = I18nCommand.MissingErrorMessages(root, keys).ToList();
Assert.Empty(missing.Select(m => $"{m.Code} ({Path.GetFileName(m.File)})"));
var withoutOne = keys.Where(k => k != "Server.Error.RenderExists").ToHashSet(StringComparer.Ordinal);
var reported = I18nCommand.MissingErrorMessages(root, withoutOne).ToList();
Assert.Count(1, reported);
Assert.Equal(("render_exists", "Server.Error.RenderExists", "RenderUploads.cs"), (reported[0].Code, reported[0].Key, Path.GetFileName(reported[0].File)));
}
}