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
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>
173 lines
8.6 KiB
C#
173 lines
8.6 KiB
C#
using Chronos.Core.Packaging;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Packaging;
|
|
|
|
public sealed class PayloadRoundTripTests(TestContext context)
|
|
{
|
|
private readonly PackagingFixture _fx = new(context);
|
|
|
|
[Test]
|
|
public void ExtractsNestedEmptyUnicodeAndIncompressibleFilesExactly()
|
|
{
|
|
var files = new (string Path, byte[] Content)[]
|
|
{
|
|
("Chronos.exe", PackagingFixture.Text("MZ program body ", 4000)),
|
|
("lib/deep/er/still/config.json", PackagingFixture.Text("{\"a\":1}", 50)),
|
|
("empty.txt", []),
|
|
("città/日本語 ✓.txt", PackagingFixture.Text("ciao 世界 ", 300)),
|
|
("media/noise.bin", PackagingFixture.Random(3 << 20, seed: 11)),
|
|
};
|
|
var app = _fx.Folder("app", files);
|
|
var installer = _fx.Pack(_fx.Stub(), PackagingFixture.Source(new PayloadComponentSource("Chronos", "Chronos", true, app)));
|
|
|
|
using var reader = PayloadReader.Open(installer);
|
|
var manifest = reader.Manifest;
|
|
Assert.Equal("Chronos", manifest.Product);
|
|
Assert.Equal("1.2.3", manifest.Version);
|
|
Assert.Count(files.Length, manifest.Files);
|
|
Assert.Equal(files.Sum(f => (long)f.Content.Length), manifest.Components[0].EstimatedSize);
|
|
Assert.Equal(PayloadCompression.Stored, manifest.Files.Single(f => f.Path == "media/noise.bin").Compression);
|
|
Assert.Equal(PayloadCompression.Deflate, manifest.Files.Single(f => f.Path == "Chronos.exe").Compression);
|
|
var empty = manifest.Files.Single(f => f.Path == "empty.txt");
|
|
Assert.Equal(0L, empty.Length);
|
|
|
|
var target = context.CreateTempDirectory("extract");
|
|
reader.Extract(manifest.FilesFor(["Chronos"]), target);
|
|
foreach (var (relative, content) in files)
|
|
{
|
|
var path = Path.Combine(target, relative.Replace('/', Path.DirectorySeparatorChar));
|
|
Assert.BytesEqual(content, File.ReadAllBytes(path), relative);
|
|
Assert.Equal(PackagingFixture.FixedTime, File.GetLastWriteTimeUtc(path), relative);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void ReportsProgressUpToTheTotalSize()
|
|
{
|
|
var app = _fx.Folder("app", ("a.bin", PackagingFixture.Random(9 << 20, 1)), ("b.txt", PackagingFixture.Text("b", 10)));
|
|
var installer = _fx.Pack(_fx.Stub(), PackagingFixture.Source(new PayloadComponentSource("Chronos", "Chronos", true, app)));
|
|
using var reader = PayloadReader.Open(installer);
|
|
var reports = new List<PayloadProgress>();
|
|
reader.Extract(reader.Manifest.Files, context.CreateTempDirectory(), new SyncProgress<PayloadProgress>(reports.Add));
|
|
Assert.True(reports.Count >= 3);
|
|
Assert.Monotonic(reports.Select(r => (double)r.Done));
|
|
Assert.Equal(reports[^1].Total, reports[^1].Done);
|
|
Assert.Equal((9L << 20) + 10, reports[^1].Total);
|
|
}
|
|
|
|
[Test]
|
|
public void IdenticalInputsProduceIdenticalInstallers()
|
|
{
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app", 999)), ("sub/z.txt", PackagingFixture.Text("z")), ("sub/a.txt", PackagingFixture.Text("a")));
|
|
var up = _fx.Folder("uploader", ("Chronos.Uploader.exe", PackagingFixture.Text("uploader", 500)));
|
|
var stub = _fx.Stub();
|
|
var source = PackagingFixture.Source(
|
|
new PayloadComponentSource("Chronos", "Chronos", true, app),
|
|
new PayloadComponentSource("Uploader", "Chronos Uploader", false, up));
|
|
var first = _fx.Pack(stub, source, "first.exe");
|
|
var second = _fx.Pack(stub, source, "second.exe");
|
|
Assert.BytesEqual(File.ReadAllBytes(first), File.ReadAllBytes(second));
|
|
Assert.Equal(0L, new FileInfo(first).Length % PayloadFormat.Alignment);
|
|
}
|
|
|
|
[Test]
|
|
public void SharedFilesAreStoredOnceAndInstalledOnce()
|
|
{
|
|
var shared = PackagingFixture.Text("shared runtime ", 2000);
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app", 100)), ("runtime.dll", shared));
|
|
var up = _fx.Folder("uploader", ("Chronos.Uploader.exe", PackagingFixture.Text("up", 100)), ("runtime.dll", shared));
|
|
var installer = _fx.Pack(_fx.Stub(), PackagingFixture.Source(
|
|
new PayloadComponentSource("Chronos", "Chronos", true, app),
|
|
new PayloadComponentSource("Uploader", "Uploader", true, up)));
|
|
|
|
using var reader = PayloadReader.Open(installer);
|
|
var copies = reader.Manifest.Files.Where(f => f.Path == "runtime.dll").ToList();
|
|
Assert.Count(2, copies);
|
|
Assert.Equal(copies[0].Offset, copies[1].Offset);
|
|
var both = reader.Manifest.FilesFor(["Chronos", "Uploader"]);
|
|
Assert.Count(3, both);
|
|
Assert.Count(2, reader.Manifest.FilesFor(["uploader"]));
|
|
Assert.Throws<ArgumentException>(() => reader.Manifest.FilesFor(["Server"]));
|
|
}
|
|
|
|
[Test]
|
|
public void DifferentContentAtTheSamePathAcrossComponentsIsRejected()
|
|
{
|
|
var app = _fx.Folder("app", ("same.dll", PackagingFixture.Text("one")));
|
|
var up = _fx.Folder("uploader", ("same.dll", PackagingFixture.Text("two")));
|
|
var ex = Assert.Throws<PayloadException>(() => _fx.Pack(_fx.Stub(), PackagingFixture.Source(
|
|
new PayloadComponentSource("Chronos", "Chronos", true, app),
|
|
new PayloadComponentSource("Uploader", "Uploader", true, up))));
|
|
Assert.Equal(PayloadError.Corrupt, ex.Error);
|
|
}
|
|
|
|
[Test]
|
|
public void ShortcutsAndAssociationsSurviveTheRoundTrip()
|
|
{
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app")));
|
|
var source = new PayloadSource
|
|
{
|
|
Product = "Chronos",
|
|
Version = "2.0.0-beta.1",
|
|
Components = [new PayloadComponentSource("Chronos", "Chronos", true, app)],
|
|
Shortcuts = [new PayloadShortcut { Component = "Chronos", Name = "Chronos", Target = "Chronos.exe", StartMenu = true, Desktop = true }],
|
|
Associations = [new PayloadAssociation { Component = "Chronos", Extension = ".chronos", ProgId = "Chronos.Project", Description = "Chronos project", Target = "Chronos.exe" }],
|
|
};
|
|
using var reader = PayloadReader.Open(_fx.Pack(_fx.Stub(), source));
|
|
var shortcut = reader.Manifest.Shortcuts.Single();
|
|
Assert.True(shortcut.Desktop && shortcut.StartMenu);
|
|
Assert.Equal("Chronos.exe", shortcut.Target);
|
|
Assert.Equal("Chronos.Project", reader.Manifest.Associations.Single().ProgId);
|
|
}
|
|
|
|
[Test]
|
|
public void ShortcutToAFileOutsideItsComponentIsRejected()
|
|
{
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app")));
|
|
var source = new PayloadSource
|
|
{
|
|
Product = "Chronos",
|
|
Version = "1.0.0",
|
|
Components = [new PayloadComponentSource("Chronos", "Chronos", true, app)],
|
|
Shortcuts = [new PayloadShortcut { Component = "Chronos", Name = "Missing", Target = "Missing.exe", StartMenu = true }],
|
|
};
|
|
Assert.Throws<PayloadException>(() => _fx.Pack(_fx.Stub(), source));
|
|
}
|
|
|
|
[Test]
|
|
public void StubCopyEndsAtThePayload()
|
|
{
|
|
var stub = _fx.Stub(10_000);
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app", 10)));
|
|
using var reader = PayloadReader.Open(_fx.Pack(stub, PackagingFixture.Source(new PayloadComponentSource("Chronos", "Chronos", true, app))));
|
|
Assert.Equal(10_000L, reader.PayloadOffset);
|
|
var copy = Path.Combine(context.CreateTempDirectory(), "Uninstall Chronos.exe");
|
|
reader.WriteStub(copy);
|
|
Assert.BytesEqual(File.ReadAllBytes(stub), File.ReadAllBytes(copy));
|
|
Assert.Equal(PayloadError.NotFound, Assert.Throws<PayloadException>(() => PayloadReader.Open(copy)).Error);
|
|
}
|
|
|
|
[Test]
|
|
public void OutputInsideAComponentFolderIsRefused()
|
|
{
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app")));
|
|
Assert.Throws<ArgumentException>(() => PayloadWriter.Write(_fx.Stub(), PackagingFixture.Source(new PayloadComponentSource("Chronos", "Chronos", true, app)), Path.Combine(app, "setup.exe")));
|
|
}
|
|
|
|
[Test]
|
|
public void AnInstallerCannotBeUsedAsStub()
|
|
{
|
|
var app = _fx.Folder("app", ("Chronos.exe", PackagingFixture.Text("app")));
|
|
var source = PackagingFixture.Source(new PayloadComponentSource("Chronos", "Chronos", true, app));
|
|
var installer = _fx.Pack(_fx.Stub(), source);
|
|
Assert.Throws<ArgumentException>(() => _fx.Pack(installer, source, "nested.exe"));
|
|
}
|
|
|
|
/// <summary>Synchronous <see cref="IProgress{T}"/> (Progress<T> posts to the thread pool).</summary>
|
|
private sealed class SyncProgress<T>(Action<T> report) : IProgress<T>
|
|
{
|
|
public void Report(T value) => report(value);
|
|
}
|
|
}
|