build: one version for the app and the plugin

D11 replaces an installed plugin only when the shipped manifest is
newer, but the manifest version was kept by hand and still said
1.0.0.1, the version of a test build installed before the snapshot
sharing and appPath fixes, so that stale plugin was never replaced.
Directory.Build.props now holds the only version, 1.0.1; publish.py
stamps it into the shipped manifest and the app shows it in its title.

Tests that waited on real time (file retry, popup expiry) use
controlled timers, and real process waits have wider margins.

Refs #1
This commit is contained in:
Florian Schmidt
2026-10-14 21:08:22 +02:00
parent 5c5973aa6c
commit 15c7e684bb
15 changed files with 126 additions and 18 deletions
@@ -28,7 +28,7 @@ public class IntegrationTests
process.Start();
try
{
await process.WaitForExitAsync(TestContext.Current.CancellationToken);
await process.WaitForExitAsync(TestContext.Current.CancellationToken).WaitAsync(TimeSpan.FromSeconds(90), TestContext.Current.CancellationToken);
using var report = JsonDocument.Parse(File.ReadAllText(reportPath));
Assert.False(report.RootElement.GetProperty("HostHasConsole").GetBoolean());
Assert.False(report.RootElement.GetProperty("HostInputValid").GetBoolean());
+1 -1
View File
@@ -31,7 +31,7 @@ public class ProcessTests
{
using var directory = new TestDirectory();
var result = await new ProcessRunner().RunAsync(new(new("dotnet", []), ["--info"], directory.Path,
TimeSpan.FromSeconds(10), OutputLimit: 50), TestContext.Current.CancellationToken);
TimeSpan.FromSeconds(60), OutputLimit: 50), TestContext.Current.CancellationToken);
Assert.Equal(0, result.ExitCode);
Assert.Equal(50, result.Output.Length);
Assert.True(result.OutputTruncated);
+14 -6
View File
@@ -1,4 +1,3 @@
using System.Diagnostics;
using FinalToken.Core.Collectors;
using Xunit;
@@ -59,9 +58,15 @@ public class ReworkTests
using var directory = new TestDirectory();
var path = directory.Write("blocked.json", "old");
using var reader = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var watch = Stopwatch.StartNew();
await Assert.ThrowsAsync<IOException>(() => AtomicFile.WriteAsync(path, "new", TestContext.Current.CancellationToken));
Assert.InRange(watch.Elapsed.TotalMilliseconds, 400, 3000);
var clock = new TestClock();
var write = AtomicFile.WriteAsync(path, "new", TestContext.Current.CancellationToken, clock);
for (var attempt = 0; attempt < 10; attempt++)
{
Assert.Equal(TimeSpan.FromMilliseconds(50), await clock.NextTimerAsync(TestContext.Current.CancellationToken));
Assert.False(write.IsCompleted);
clock.Advance(TimeSpan.FromMilliseconds(50));
}
await Assert.ThrowsAsync<IOException>(() => write);
Assert.Equal("old", File.ReadAllText(path));
Assert.Empty(Directory.GetFiles(directory.Path, "*.tmp"));
}
@@ -196,9 +201,12 @@ public class ReworkTests
using var directory = new TestDirectory();
var path = directory.Write("briefly-blocked.json", "old");
using var reader = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var write = AtomicFile.WriteAsync(path, "new", TestContext.Current.CancellationToken);
await Task.Delay(TimeSpan.FromMilliseconds(120), TestContext.Current.CancellationToken);
var clock = new TestClock();
var write = AtomicFile.WriteAsync(path, "new", TestContext.Current.CancellationToken, clock);
Assert.Equal(TimeSpan.FromMilliseconds(50), await clock.NextTimerAsync(TestContext.Current.CancellationToken));
Assert.False(write.IsCompleted);
reader.Dispose();
clock.Advance(TimeSpan.FromMilliseconds(50));
await write;
Assert.Equal("new", File.ReadAllText(path));
}
@@ -11,6 +11,24 @@ public sealed class InstallerTests : IDisposable
private string Installed => Path.Combine(Plugins, PluginInstaller.FolderName);
public InstallerTests() => Write(Shipped, "1.0.0.0", "new");
[Fact]
public async Task ReleasePluginReportsOldDevelopmentCopyAsOutdated()
{
var shipped = Environment.GetEnvironmentVariable("FINALTOKEN_TEST_SHIPPED_PLUGIN");
if (shipped is null)
{
Write(Shipped, typeof(PluginInstaller).Assembly.GetName().Version!.ToString(), "new");
shipped = Shipped;
}
Write(Installed, "1.0.0.1", "old development copy");
var process = new FakeProcesses();
var installer = new PluginInstaller(shipped, new(Plugins, "fake", "fake"), process);
var status = await installer.GetStatusAsync(TestContext.Current.CancellationToken);
Assert.Equal(PluginInstallState.Outdated, status.State);
Assert.Equal(typeof(PluginInstaller).Assembly.GetName().Version!.ToString(), status.ShippedVersion);
Assert.Equal("1.0.0.1", status.InstalledVersion);
Assert.Equal(0, process.Stops); Assert.Equal(0, process.Starts);
}
[Fact]
public async Task FreshInstallDoesNotStartStoppedHost()
{
var process = new FakeProcesses();
@@ -1,4 +1,5 @@
using FinalToken.Core.Processes;
using System.Threading.Channels;
namespace FinalToken.Core.Tests;
@@ -18,6 +19,8 @@ public sealed class TestDirectory : IDisposable
public sealed class TestClock : TimeProvider
{
private readonly Channel<TimeSpan> scheduled = Channel.CreateUnbounded<TimeSpan>();
public ValueTask<TimeSpan> NextTimerAsync(CancellationToken cancellationToken) => scheduled.Reader.ReadAsync(cancellationToken);
private readonly Lock gate = new();
private DateTimeOffset now = new(2026, 10, 14, 16, 0, 0, TimeSpan.Zero);
private readonly List<TestTimer> timers = [];
@@ -40,6 +43,7 @@ public sealed class TestClock : TimeProvider
var timer = new TestTimer(this, callback, state, period);
timer.Change(dueTime, period);
timers.Add(timer);
scheduled.Writer.TryWrite(dueTime);
return timer;
}
}