Warn on improperly disposed tests. (#18594)

This commit is contained in:
Leon Friedrich
2023-08-03 15:07:21 +12:00
committed by GitHub
parent ec749270af
commit 5a9317027f
3 changed files with 10 additions and 2 deletions

View File

@@ -947,6 +947,10 @@ public sealed class PairTracker : IAsyncDisposable
_testOut = testOut;
}
// Convenience properties.
public RobustIntegrationTest.ServerIntegrationInstance Server => Pair.Server;
public RobustIntegrationTest.ClientIntegrationInstance Client => Pair.Client;
private async Task OnDirtyDispose()
{
var usageTime = UsageWatch.Elapsed;
@@ -957,6 +961,10 @@ public sealed class PairTracker : IAsyncDisposable
PoolManager.NoCheckReturn(Pair);
var disposeTime = dirtyWatch.Elapsed;
await _testOut.WriteLineAsync($"{nameof(DisposeAsync)}: Disposed pair {Pair.PairId} in {disposeTime.TotalMilliseconds} ms");
// Test pairs should only dirty dispose if they are failing. If they are not failing, this probably happened
// because someone forgot to clean-return the pair.
Assert.Warn("Test was dirty-disposed.");
}
private async Task OnCleanDispose()