Warn on improperly disposed tests. (#18594)
This commit is contained in:
2
.github/workflows/build-test-debug.yml
vendored
2
.github/workflows/build-test-debug.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$env:DOTNET_gcServer=1
|
$env:DOTNET_gcServer=1
|
||||||
dotnet test --no-build --configuration DebugOpt Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0
|
dotnet test --no-build --configuration DebugOpt Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0 NUnit.MapWarningTo=Failed
|
||||||
ci-success:
|
ci-success:
|
||||||
name: Build & Test Debug
|
name: Build & Test Debug
|
||||||
needs:
|
needs:
|
||||||
|
|||||||
2
.github/workflows/build-test-release.yml
vendored
2
.github/workflows/build-test-release.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$env:DOTNET_gcServer=1
|
$env:DOTNET_gcServer=1
|
||||||
dotnet test --configuration Tools --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0
|
dotnet test --configuration Tools --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0 NUnit.MapWarningTo=Failed
|
||||||
ci-success:
|
ci-success:
|
||||||
name: Build & Test Release
|
name: Build & Test Release
|
||||||
needs:
|
needs:
|
||||||
|
|||||||
@@ -947,6 +947,10 @@ public sealed class PairTracker : IAsyncDisposable
|
|||||||
_testOut = testOut;
|
_testOut = testOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convenience properties.
|
||||||
|
public RobustIntegrationTest.ServerIntegrationInstance Server => Pair.Server;
|
||||||
|
public RobustIntegrationTest.ClientIntegrationInstance Client => Pair.Client;
|
||||||
|
|
||||||
private async Task OnDirtyDispose()
|
private async Task OnDirtyDispose()
|
||||||
{
|
{
|
||||||
var usageTime = UsageWatch.Elapsed;
|
var usageTime = UsageWatch.Elapsed;
|
||||||
@@ -957,6 +961,10 @@ public sealed class PairTracker : IAsyncDisposable
|
|||||||
PoolManager.NoCheckReturn(Pair);
|
PoolManager.NoCheckReturn(Pair);
|
||||||
var disposeTime = dirtyWatch.Elapsed;
|
var disposeTime = dirtyWatch.Elapsed;
|
||||||
await _testOut.WriteLineAsync($"{nameof(DisposeAsync)}: Disposed pair {Pair.PairId} in {disposeTime.TotalMilliseconds} ms");
|
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()
|
private async Task OnCleanDispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user