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:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user