Prove che cadevano con il runner carico (#46)
Le prove cadevano a ogni carico della CI, ogni volta prove diverse. Dietro alcune c'erano difetti veri: FebeDatabase lasciava i file aperti dopo DisposeAsync (comandi SQLite non chiusi, pool di lettura chiuso dopo lo scrittore), e il WAL spariva durante lo spostamento della cartella Dati; la scheda dell'account senza statistiche leggeva i file di tutta la libreria; l'arresto di FebeApp non aspettava i lavori aggiunti da un avvio in corso. Chromium ha 120 s per avviarsi e aprire la prima scheda, e il ricollegamento smette appena il processo cambia. Nelle prove i limiti di tempo diventano protezioni contro un blocco: attese per condizione con un aiuto comune, limiti per classe nella prova di scala con il tempo migliore, porta 0 e stderr di Chromium nel browser delle prove, e la prova di «Scollega» di WebView2 controlla che il processo esca davvero. Provato su Windows con tutti i core occupati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2e64c09e8
commit
0775a1460f
34 files changed
+875
-245
No files matched your search
@@ -380,14 +380,21 @@ public sealed class DesktopLogicTests
|
||||
Assert.AreEqual(DataFolderLockOutcome.HeldByAnother, DataFolderLock.TryAcquire(alias, out var second, TimeSpan.Zero));
|
||||
Assert.IsNull(second);
|
||||
|
||||
// Held for a moment only (an antivirus looking at the file): the start waits instead of giving up.
|
||||
var release = Task.Run(async () =>
|
||||
// Held for a moment only (an antivirus looking at the file): the start waits instead of giving up. The release
|
||||
// runs on a thread of its own, not on the thread pool, which the parallel tests may keep busy for seconds (#46);
|
||||
// the patience only bounds a lock that is never released, and the wait ends as soon as the file is free.
|
||||
var released = 0;
|
||||
var releaser = new Thread(() =>
|
||||
{
|
||||
await Task.Delay(300, TestContext.CancellationToken);
|
||||
Thread.Sleep(300);
|
||||
Volatile.Write(ref released, 1);
|
||||
first.Dispose();
|
||||
}, TestContext.CancellationToken);
|
||||
Assert.AreEqual(DataFolderLockOutcome.Acquired, DataFolderLock.TryAcquire(alias, out var later, TimeSpan.FromSeconds(10)));
|
||||
release.Wait(TestContext.CancellationToken);
|
||||
})
|
||||
{ IsBackground = true };
|
||||
releaser.Start();
|
||||
Assert.AreEqual(DataFolderLockOutcome.Acquired, DataFolderLock.TryAcquire(alias, out var later, TimeSpan.FromSeconds(60)));
|
||||
Assert.AreEqual(1, Volatile.Read(ref released), "The lock was taken only once the other one let it go.");
|
||||
releaser.Join();
|
||||
later!.Dispose();
|
||||
|
||||
// A Data folder where nothing can be written: the start-up checks explain it, the lock does not decide.
|
||||
|
||||
@@ -153,6 +153,7 @@ public sealed class WebView2CdpSessionTests
|
||||
await using var session = new WebView2CdpSession(log);
|
||||
session.Attach(devTools);
|
||||
var bodies = new ConcurrentQueue<string>();
|
||||
var bodyArrived = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using var bad = session.On("Network.loadingFinished", _ => throw new InvalidOperationException(Secret));
|
||||
|
||||
// The pattern of ResponseTap: the handler queues the command, it never blocks.
|
||||
@@ -160,13 +161,13 @@ public sealed class WebView2CdpSessionTests
|
||||
{
|
||||
var body = await session.SendAsync("Network.getResponseBody", new JsonObject { ["requestId"] = e.GetProperty("requestId").GetString() });
|
||||
bodies.Enqueue(body.GetProperty("body").GetString()!);
|
||||
bodyArrived.TrySetResult();
|
||||
}));
|
||||
devTools.Raise("Network.loadingFinished", """{"requestId":"7"}""");
|
||||
await session.DrainAsync();
|
||||
for (var i = 0; i < 50 && bodies.IsEmpty; i++)
|
||||
{
|
||||
await Task.Delay(20, TestContext.CancellationToken);
|
||||
}
|
||||
|
||||
// The handler's Task.Run must get a pool thread: by condition, with a generous limit (#46).
|
||||
await bodyArrived.Task.WaitAsync(TimeSpan.FromSeconds(30), TestContext.CancellationToken);
|
||||
|
||||
Assert.AreEqual("x", bodies.Single());
|
||||
StringAssert.Contains(log.All, "Network.loadingFinished");
|
||||
|
||||
Reference in new issue
Block a user