From d8df5c88cf22b9a90fb7a48b73ee3fa7dcf7eb07 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 Dec 2024 11:29:15 -0700 Subject: [PATCH 01/12] Activate GitHub Actions test reporting --- Directory.Packages.props | 1 + azure-pipelines/dotnet-test-cloud.ps1 | 35 ++++++++++++++++++++++++--- test/Directory.Build.props | 3 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1023acab..1f94284a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,6 +6,7 @@ true + diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 33ff3d7c..c0be8672 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -25,6 +25,8 @@ Param( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" +$TestLogsPath = "$ArtifactStagingFolder/test_logs" +if (!(Test-Path $TestLogsPath)) { New-Item -ItemType Directory -Path $TestLogsPath | Out-Null } $dotnet = 'dotnet' if ($x86) { @@ -44,21 +46,46 @@ if ($x86) { } } +$dotnetTestArgs = @() +$dotnetTestArgs2 = @() + +# The GitHubActions test logger fails when combined with certain switches, but only on mac/linux. +# We avoid those switches in that specific context. +# Failure symptoms when using the wrong switch combinations on mac/linux are (depending on the switches) EITHER: +# - The test runner fails with exit code 1 (and no error message) +# - The test runner succeeds but the GitHubActions logger only adds annotations on Windows agents. +# See https://github.com/Tyrrrz/GitHubActionsTestLogger/discussions/37 for more info. +# Thus, the mess of conditions you see below, in order to get GitHubActions to work +# without undermining other value we have when running in other contexts. +if ($env:GITHUB_WORKFLOW -and ($IsLinux -or $IsMacOS)) { + $dotnetTestArgs += '--collect','Xplat Code Coverage' + $dotnetTestArgs2 += 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover' +} else { + $dotnetTestArgs += '--diag','$$TestLogsPath/diag.log;TraceLevel=info' + $dotnetTestArgs += '--collect','Code Coverage;Format=cobertura' + $dotnetTestArgs += '--settings',"$PSScriptRoot/test.runsettings" +} + +if ($env:GITHUB_WORKFLOW) { + $dotnetTestArgs += '--logger','GitHubActions' + $dotnetTestArgs2 += 'RunConfiguration.CollectSourceInformation=true' +} + & $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` - --collect "Code Coverage;Format=cobertura" ` - --settings "$PSScriptRoot/test.runsettings" ` --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` - --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` --logger trx ` + @dotnetTestArgs ` + -- ` + @dotnetTestArgs2 $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ + Copy-Item $_ -Destination $TestLogsPath/ if ($PublishResults) { $x = [xml](Get-Content -LiteralPath $_) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 6c7aa71d..65b3bade 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,4 +7,7 @@ true + + + From d2f4c5e339b1be2bb8bccff6ef13b0a3fe63c81e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 Dec 2024 15:10:28 -0700 Subject: [PATCH 02/12] Revert "Merge pull request #319 from AArnott/betterTestingLibTemplate" This reverts commit 01eeb1aff44be490aea525baa92f89240ba2f682, reversing changes made to 0a42cd9afd1e40f6a5392850a5115ca5f42dfd9a. --- Directory.Packages.props | 1 - azure-pipelines/dotnet-test-cloud.ps1 | 35 +++------------------------ test/Directory.Build.props | 3 --- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1f94284a..1023acab 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,6 @@ true - diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index c0be8672..33ff3d7c 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -25,8 +25,6 @@ Param( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" -$TestLogsPath = "$ArtifactStagingFolder/test_logs" -if (!(Test-Path $TestLogsPath)) { New-Item -ItemType Directory -Path $TestLogsPath | Out-Null } $dotnet = 'dotnet' if ($x86) { @@ -46,46 +44,21 @@ if ($x86) { } } -$dotnetTestArgs = @() -$dotnetTestArgs2 = @() - -# The GitHubActions test logger fails when combined with certain switches, but only on mac/linux. -# We avoid those switches in that specific context. -# Failure symptoms when using the wrong switch combinations on mac/linux are (depending on the switches) EITHER: -# - The test runner fails with exit code 1 (and no error message) -# - The test runner succeeds but the GitHubActions logger only adds annotations on Windows agents. -# See https://github.com/Tyrrrz/GitHubActionsTestLogger/discussions/37 for more info. -# Thus, the mess of conditions you see below, in order to get GitHubActions to work -# without undermining other value we have when running in other contexts. -if ($env:GITHUB_WORKFLOW -and ($IsLinux -or $IsMacOS)) { - $dotnetTestArgs += '--collect','Xplat Code Coverage' - $dotnetTestArgs2 += 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover' -} else { - $dotnetTestArgs += '--diag','$$TestLogsPath/diag.log;TraceLevel=info' - $dotnetTestArgs += '--collect','Code Coverage;Format=cobertura' - $dotnetTestArgs += '--settings',"$PSScriptRoot/test.runsettings" -} - -if ($env:GITHUB_WORKFLOW) { - $dotnetTestArgs += '--logger','GitHubActions' - $dotnetTestArgs2 += 'RunConfiguration.CollectSourceInformation=true' -} - & $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` + --collect "Code Coverage;Format=cobertura" ` + --settings "$PSScriptRoot/test.runsettings" ` --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` + --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` --logger trx ` - @dotnetTestArgs ` - -- ` - @dotnetTestArgs2 $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $TestLogsPath/ + Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ if ($PublishResults) { $x = [xml](Get-Content -LiteralPath $_) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 65b3bade..6c7aa71d 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,7 +7,4 @@ true - - - From 7b18fd08172526499129f394ae71878cfc0acc63 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 08:14:30 -0700 Subject: [PATCH 03/12] Resolve schema validation error in VS Code for docfx yml files --- docfx/docs/toc.yml | 2 +- docfx/toc.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docfx/docs/toc.yml b/docfx/docs/toc.yml index 36a38020..518ffadd 100644 --- a/docfx/docs/toc.yml +++ b/docfx/docs/toc.yml @@ -1,5 +1,5 @@ +items: - name: Features href: features.md - name: Getting Started href: getting-started.md - diff --git a/docfx/toc.yml b/docfx/toc.yml index abd17b8c..8e9a6700 100644 --- a/docfx/toc.yml +++ b/docfx/toc.yml @@ -1,3 +1,4 @@ +items: - name: Docs href: docs/ - name: API From ad4ff0f092dfc147fdb6f5f2151c7071c9b8bc6e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:19:52 -0700 Subject: [PATCH 04/12] Bump xunit.runner.visualstudio to 3.0.0 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1023acab..b10eaee7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From 2e9751f002252714719de4d2f914156902b8aae5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:19:58 -0700 Subject: [PATCH 05/12] Bump .NET SDK to 9.0.101 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 088f23e1..f3e0b323 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100", + "version": "9.0.101", "rollForward": "patch", "allowPrerelease": false } From 0c33c695660191469a486f8f9de195f378f1bd2d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:35:40 -0700 Subject: [PATCH 06/12] Organize Directory.Packages.props to reduce merge conflicts going forward --- Directory.Packages.props | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index b10eaee7..32113f54 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,11 +6,17 @@ true + + + + + + From 99ee1fcd49f2d7ce9cf8e5c1d2927260548d0171 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 22 Dec 2024 18:50:42 -0700 Subject: [PATCH 07/12] Bump to Xunit v3 --- Directory.Packages.props | 4 ++-- test/Library.Tests/Library.Tests.csproj | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 32113f54..63808e7c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,7 @@ - + @@ -24,4 +24,4 @@ - + \ No newline at end of file diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index a853dc7d..5cbc1e1f 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -3,6 +3,7 @@ net8.0 $(TargetFrameworks);net472 + Exe @@ -13,7 +14,7 @@ - + From 94eba4a33a15fd28a0693bba3e3e5086d0df8d24 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Dec 2024 09:48:35 -0700 Subject: [PATCH 08/12] Build servicing branches --- .github/workflows/build.yml | 1 + azure-pipelines.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 474d90c2..fbd7115c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - 'v*.*' - validate/* pull_request: workflow_dispatch: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9867b3db..4d372fe0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,6 +3,7 @@ trigger: branches: include: - main + - 'v*.*' - 'validate/*' paths: exclude: From 275a44b6c5cb089a21ac2b2456c55d66ec172236 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Dec 2024 11:39:09 -0700 Subject: [PATCH 09/12] Do not publish artifacts on cancelled GitHub workflows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbd7115c..58e56ccc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,7 @@ jobs: shell: pwsh - name: 📢 Publish artifacts uses: ./.github/actions/publish-artifacts - if: always() + if: cancelled() == false - name: 📢 Publish code coverage results to codecov.io run: ./azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" shell: pwsh From 93d90f92c542bc2377df15916e337a6bc07048c7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Dec 2024 21:50:26 -0700 Subject: [PATCH 10/12] Xunit v3 accommodations --- Directory.Packages.props | 5 ++-- test/IsolatedTestHost/IsolatedTestHost.csproj | 3 +- test/IsolatedTestHost/TestOutputHelper.cs | 14 ++++++++- .../BufferTextWriterTests.cs | 1 - .../BufferWriterStreamTests.cs | 1 - .../FullDuplexStreamCombineTests.cs | 1 - .../FullDuplexStreamPairTests.cs | 1 - .../HalfDuplexStreamTests.cs | 1 - .../IOPipelinesStreamPipeReaderTests.cs | 3 +- .../MonitoringStreamTests.cs | 1 - .../MultiplexingProtocolExceptionTests.cs | 1 - .../MultiplexingStreamBasicTests.cs | 1 - .../MultiplexingStreamChannelOptionsTests.cs | 1 - .../MultiplexingStreamPerfTests.cs | 15 +++++----- .../MultiplexingStreamSeededChannelTests.cs | 7 ++--- .../MultiplexingStreamTests.cs | 11 ++++--- .../MultiplexingStreamV2Tests.cs | 1 - .../MultiplexingStreamV3Tests.cs | 1 - .../Nerdbank.Streams.Tests.csproj | 5 ++-- .../NestedPipeReaderTests.cs | 5 ++-- .../NestedStreamTests.cs | 1 - .../PipeExtensionsTests.cs | 1 - .../PipeReaderCompletionWatcherTests.cs | 1 - .../Nerdbank.Streams.Tests/PipeStreamTests.cs | 1 - .../PipeWriterCompletionWatcherTests.cs | 1 - .../ReadOnlySequenceStreamTests.cs | 1 - test/Nerdbank.Streams.Tests/SequenceTests.cs | 1 - .../SequenceTextReaderTests.cs | 1 - .../SimplexStreamTests.cs | 1 - .../StreamExtensionsTests.cs | 1 - .../StreamPipeReaderTestBase.cs | 9 +++--- .../StreamPipeWriterTestBase.cs | 1 - .../StreamUsePipeReaderTests.cs | 1 - .../StreamUsePipeWriterTests.cs | 1 - .../StreamUseStrictPipeReaderTests.cs | 1 - .../StreamUseStrictPipeWriterTests.cs | 1 - test/Nerdbank.Streams.Tests/SubstreamTests.cs | 1 - test/Nerdbank.Streams.Tests/TestBase.cs | 29 +++++++++++++------ .../WebSocketStreamTests.cs | 1 - .../XunitTraceListener.cs | 2 +- 40 files changed, 62 insertions(+), 74 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6d06b74a..121fe7ba 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -30,8 +30,9 @@ - - + + + diff --git a/test/IsolatedTestHost/IsolatedTestHost.csproj b/test/IsolatedTestHost/IsolatedTestHost.csproj index 997e0e3b..b740a645 100644 --- a/test/IsolatedTestHost/IsolatedTestHost.csproj +++ b/test/IsolatedTestHost/IsolatedTestHost.csproj @@ -6,8 +6,7 @@ - - + diff --git a/test/IsolatedTestHost/TestOutputHelper.cs b/test/IsolatedTestHost/TestOutputHelper.cs index eb0e5904..a6323373 100644 --- a/test/IsolatedTestHost/TestOutputHelper.cs +++ b/test/IsolatedTestHost/TestOutputHelper.cs @@ -4,10 +4,22 @@ namespace IsolatedTestHost { using System; - using Xunit.Abstractions; + using Xunit; internal class TestOutputHelper : ITestOutputHelper { + public string Output => throw new NotImplementedException(); + + public void Write(string message) + { + Console.Write(message); + } + + public void Write(string format, params object[] args) + { + Console.Write(format, args); + } + public void WriteLine(string message) { Console.WriteLine(message); diff --git a/test/Nerdbank.Streams.Tests/BufferTextWriterTests.cs b/test/Nerdbank.Streams.Tests/BufferTextWriterTests.cs index be6d6fb5..c566d9ab 100644 --- a/test/Nerdbank.Streams.Tests/BufferTextWriterTests.cs +++ b/test/Nerdbank.Streams.Tests/BufferTextWriterTests.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class BufferTextWriterTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/BufferWriterStreamTests.cs b/test/Nerdbank.Streams.Tests/BufferWriterStreamTests.cs index 44a9c03d..02be4191 100644 --- a/test/Nerdbank.Streams.Tests/BufferWriterStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/BufferWriterStreamTests.cs @@ -11,7 +11,6 @@ using Microsoft; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class BufferWriterStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/FullDuplexStreamCombineTests.cs b/test/Nerdbank.Streams.Tests/FullDuplexStreamCombineTests.cs index 850171c8..ef04742b 100644 --- a/test/Nerdbank.Streams.Tests/FullDuplexStreamCombineTests.cs +++ b/test/Nerdbank.Streams.Tests/FullDuplexStreamCombineTests.cs @@ -8,7 +8,6 @@ using NSubstitute; using NSubstitute.ReceivedExtensions; using Xunit; -using Xunit.Abstractions; public class FullDuplexStreamCombineTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/FullDuplexStreamPairTests.cs b/test/Nerdbank.Streams.Tests/FullDuplexStreamPairTests.cs index 03e24e6b..ed56b26c 100644 --- a/test/Nerdbank.Streams.Tests/FullDuplexStreamPairTests.cs +++ b/test/Nerdbank.Streams.Tests/FullDuplexStreamPairTests.cs @@ -9,7 +9,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class FullDuplexStreamPairTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/HalfDuplexStreamTests.cs b/test/Nerdbank.Streams.Tests/HalfDuplexStreamTests.cs index bed292d8..27dbb554 100644 --- a/test/Nerdbank.Streams.Tests/HalfDuplexStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/HalfDuplexStreamTests.cs @@ -11,7 +11,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; #pragma warning disable CS0618 // Type or member is obsolete diff --git a/test/Nerdbank.Streams.Tests/IOPipelinesStreamPipeReaderTests.cs b/test/Nerdbank.Streams.Tests/IOPipelinesStreamPipeReaderTests.cs index 9a4de82d..8ad7beee 100644 --- a/test/Nerdbank.Streams.Tests/IOPipelinesStreamPipeReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/IOPipelinesStreamPipeReaderTests.cs @@ -1,9 +1,8 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.IO; using System.IO.Pipelines; -using Xunit.Abstractions; +using Xunit; public class IOPipelinesStreamPipeReaderTests : StreamPipeReaderTestBase { diff --git a/test/Nerdbank.Streams.Tests/MonitoringStreamTests.cs b/test/Nerdbank.Streams.Tests/MonitoringStreamTests.cs index 8a3091ee..2b65826e 100644 --- a/test/Nerdbank.Streams.Tests/MonitoringStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/MonitoringStreamTests.cs @@ -6,7 +6,6 @@ using Nerdbank.Streams; using NSubstitute; using Xunit; -using Xunit.Abstractions; public class MonitoringStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/MultiplexingProtocolExceptionTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingProtocolExceptionTests.cs index b2eb876a..96f2cb60 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingProtocolExceptionTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingProtocolExceptionTests.cs @@ -4,7 +4,6 @@ using System; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class MultiplexingProtocolExceptionTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamBasicTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamBasicTests.cs index b9d01ce9..b5bed904 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamBasicTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamBasicTests.cs @@ -5,7 +5,6 @@ using Nerdbank.Streams; using NSubstitute; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamBasicTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamChannelOptionsTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamChannelOptionsTests.cs index 119eedd5..510ac286 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamChannelOptionsTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamChannelOptionsTests.cs @@ -6,7 +6,6 @@ using System.IO.Pipelines; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamChannelOptionsTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs index e3822575..532aa926 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs @@ -14,7 +14,6 @@ using Nerdbank.Streams; using StreamJsonRpc; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamPerfTests : TestBase, IAsyncLifetime { @@ -32,27 +31,27 @@ public MultiplexingStreamPerfTests(ITestOutputHelper logger) this.clientPipe = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous); } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { Task connectTask = this.serverPipe.WaitForConnectionAsync(this.TimeoutToken); await this.clientPipe.ConnectAsync(this.TimeoutToken); await connectTask; } - public Task DisposeAsync() + public ValueTask DisposeAsync() { this.serverPipe.Dispose(); this.clientPipe.Dispose(); - return Task.CompletedTask; + return default; } - [SkippableFact] + [Fact] public Task JsonRpcPerf_Pipe() => this.JsonRpcPerf(useChannel: false); - [SkippableFact] + [Fact] public Task JsonRpcPerf_Channel() => this.JsonRpcPerf(useChannel: true); - [SkippableFact] + [Fact] public async Task SendLargePayloadOnOneStream() { if (await this.ExecuteInIsolationAsync()) @@ -103,7 +102,7 @@ await Task.WhenAll( } } - [SkippableFact] + [Fact] public async Task SendLargePayloadOnManyChannels() { if (await this.ExecuteInIsolationAsync()) diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs index bb6ed3f2..4665b069 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs @@ -15,7 +15,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamSeededChannelTests : TestBase, IAsyncLifetime { @@ -61,12 +60,12 @@ public MultiplexingStreamSeededChannelTests(ITestOutputHelper logger) this.mx2 = MultiplexingStream.Create(this.transport2, new MultiplexingStream.Options(this.options) { TraceSource = mx2TraceSource, DefaultChannelTraceSourceFactoryWithQualifier = mx2TraceSourceFactory }); } - public Task InitializeAsync() + public ValueTask InitializeAsync() { - return Task.CompletedTask; + return default; } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { await (this.mx1?.DisposeAsync() ?? default); await (this.mx2?.DisposeAsync() ?? default); diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs index e8b645a5..524e280c 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs @@ -15,7 +15,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; #pragma warning disable SA1401 // Fields should be private #pragma warning disable SA1414 // Tuple types in signatures should have element names @@ -36,12 +35,12 @@ public MultiplexingStreamTests(ITestOutputHelper logger) protected virtual int ProtocolMajorVersion { get; } = 1; - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { await this.ReinitializeMxStreamsAsync(new MultiplexingStream.Options()); } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { await (this.mx1?.DisposeAsync() ?? default); await (this.mx2?.DisposeAsync() ?? default); @@ -751,7 +750,7 @@ public async Task PartialFrameSentWithoutExplicitFlush() await ReadAtLeastAsync(s2, new ArraySegment(recvBuffer), recvBuffer.Length, this.TimeoutToken); } - [SkippableTheory] + [Theory] [InlineData(true)] [InlineData(false)] public async Task CancelChannelOfferBeforeAcceptance(bool cancelFirst) @@ -778,13 +777,13 @@ public async Task CancelChannelOfferBeforeAcceptance(bool cancelFirst) int bytesRead = await acceptedStream.ReadAsync(new byte[1], 0, 1, this.TimeoutToken).WithCancellation(this.TimeoutToken); Assert.Equal(0, bytesRead); // confirm that the stream was closed. this.Logger.WriteLine("Verified the channel terminated condition."); - Skip.If(cancelFirst); + Assert.SkipWhen(cancelFirst, "Skipped"); } catch (OperationCanceledException) when (acceptedStream == null) { // In this case, the channel offer was canceled before we accepted it. this.Logger.WriteLine("Verified the channel offer was canceled before acceptance condition."); - Skip.IfNot(cancelFirst); + Assert.SkipUnless(cancelFirst, "Skipped"); } } diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs index a0fd8bb9..d0e6ece1 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs @@ -8,7 +8,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamV2Tests : MultiplexingStreamTests { diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamV3Tests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamV3Tests.cs index 660b7e51..8d336abb 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamV3Tests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamV3Tests.cs @@ -6,7 +6,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class MultiplexingStreamV3Tests : MultiplexingStreamV2Tests { diff --git a/test/Nerdbank.Streams.Tests/Nerdbank.Streams.Tests.csproj b/test/Nerdbank.Streams.Tests/Nerdbank.Streams.Tests.csproj index 9f5a5ba6..d6a2b9b1 100644 --- a/test/Nerdbank.Streams.Tests/Nerdbank.Streams.Tests.csproj +++ b/test/Nerdbank.Streams.Tests/Nerdbank.Streams.Tests.csproj @@ -2,6 +2,7 @@ net8.0 $(TargetFrameworks);net472 + Exe true @@ -32,11 +33,9 @@ - + - - diff --git a/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs b/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs index da6dbcf7..dd4dd331 100644 --- a/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class NestedPipeReaderTests : TestBase, IAsyncLifetime { @@ -20,9 +19,9 @@ public NestedPipeReaderTests(ITestOutputHelper logger) { } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => default; - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { await this.pipe.Writer.WriteAsync(OriginalBuffer, this.TimeoutToken); } diff --git a/test/Nerdbank.Streams.Tests/NestedStreamTests.cs b/test/Nerdbank.Streams.Tests/NestedStreamTests.cs index 39c9de08..82c342f0 100644 --- a/test/Nerdbank.Streams.Tests/NestedStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/NestedStreamTests.cs @@ -7,7 +7,6 @@ using Nerdbank.Streams; using NSubstitute; using Xunit; -using Xunit.Abstractions; public class NestedStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/PipeExtensionsTests.cs b/test/Nerdbank.Streams.Tests/PipeExtensionsTests.cs index 8e19635a..572a126d 100644 --- a/test/Nerdbank.Streams.Tests/PipeExtensionsTests.cs +++ b/test/Nerdbank.Streams.Tests/PipeExtensionsTests.cs @@ -9,7 +9,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; using IPC = System.IO.Pipes; public partial class PipeExtensionsTests : TestBase diff --git a/test/Nerdbank.Streams.Tests/PipeReaderCompletionWatcherTests.cs b/test/Nerdbank.Streams.Tests/PipeReaderCompletionWatcherTests.cs index df34cbbf..b3375d26 100644 --- a/test/Nerdbank.Streams.Tests/PipeReaderCompletionWatcherTests.cs +++ b/test/Nerdbank.Streams.Tests/PipeReaderCompletionWatcherTests.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class PipeReaderCompletionWatcherTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/PipeStreamTests.cs b/test/Nerdbank.Streams.Tests/PipeStreamTests.cs index 4476fbd0..ce35959b 100644 --- a/test/Nerdbank.Streams.Tests/PipeStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/PipeStreamTests.cs @@ -16,7 +16,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class PipeStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/PipeWriterCompletionWatcherTests.cs b/test/Nerdbank.Streams.Tests/PipeWriterCompletionWatcherTests.cs index 6d43d6a2..eac979cc 100644 --- a/test/Nerdbank.Streams.Tests/PipeWriterCompletionWatcherTests.cs +++ b/test/Nerdbank.Streams.Tests/PipeWriterCompletionWatcherTests.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class PipeWriterCompletionWatcherTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/ReadOnlySequenceStreamTests.cs b/test/Nerdbank.Streams.Tests/ReadOnlySequenceStreamTests.cs index 64879f60..981a1277 100644 --- a/test/Nerdbank.Streams.Tests/ReadOnlySequenceStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/ReadOnlySequenceStreamTests.cs @@ -11,7 +11,6 @@ using Microsoft; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class ReadOnlySequenceStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/SequenceTests.cs b/test/Nerdbank.Streams.Tests/SequenceTests.cs index edac250d..79282189 100644 --- a/test/Nerdbank.Streams.Tests/SequenceTests.cs +++ b/test/Nerdbank.Streams.Tests/SequenceTests.cs @@ -10,7 +10,6 @@ using Microsoft; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class SequenceTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/SequenceTextReaderTests.cs b/test/Nerdbank.Streams.Tests/SequenceTextReaderTests.cs index 377ec8c7..220a7bb2 100644 --- a/test/Nerdbank.Streams.Tests/SequenceTextReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/SequenceTextReaderTests.cs @@ -10,7 +10,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class SequenceTextReaderTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/SimplexStreamTests.cs b/test/Nerdbank.Streams.Tests/SimplexStreamTests.cs index 1212bf67..9601da06 100644 --- a/test/Nerdbank.Streams.Tests/SimplexStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/SimplexStreamTests.cs @@ -11,7 +11,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class SimplexStreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/StreamExtensionsTests.cs b/test/Nerdbank.Streams.Tests/StreamExtensionsTests.cs index 8c55dd3f..90536591 100644 --- a/test/Nerdbank.Streams.Tests/StreamExtensionsTests.cs +++ b/test/Nerdbank.Streams.Tests/StreamExtensionsTests.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public class StreamExtensionsTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/StreamPipeReaderTestBase.cs b/test/Nerdbank.Streams.Tests/StreamPipeReaderTestBase.cs index cb16770a..b2c7fe19 100644 --- a/test/Nerdbank.Streams.Tests/StreamPipeReaderTestBase.cs +++ b/test/Nerdbank.Streams.Tests/StreamPipeReaderTestBase.cs @@ -6,7 +6,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; public abstract class StreamPipeReaderTestBase : TestBase { @@ -23,10 +22,10 @@ public void ThrowsOnNull() Assert.Throws(() => this.CreatePipeReader((Stream)null!)); } - [SkippableFact] + [Fact] public async Task Stream() { - Skip.If(this is IOPipelinesStreamPipeReaderTests, "OnWriterCompleted isn't supported."); + Assert.SkipWhen(this is IOPipelinesStreamPipeReaderTests, "OnWriterCompleted isn't supported."); byte[] expectedBuffer = this.GetRandomBuffer(2048); var stream = new MemoryStream(expectedBuffer); @@ -241,10 +240,10 @@ public void AdvanceTo_BeforeRead() Assert.True(ex is InvalidCastException || ex is InvalidOperationException); } - [SkippableFact] + [Fact] public async Task OnWriterCompleted() { - Skip.If(this is IOPipelinesStreamPipeReaderTests, "OnWriterCompleted isn't supported."); + Assert.SkipWhen(this is IOPipelinesStreamPipeReaderTests, "OnWriterCompleted isn't supported."); byte[] expectedBuffer = this.GetRandomBuffer(50); var stream = new MemoryStream(expectedBuffer); PipeReader? reader = this.CreatePipeReader(stream, sizeHint: 50); diff --git a/test/Nerdbank.Streams.Tests/StreamPipeWriterTestBase.cs b/test/Nerdbank.Streams.Tests/StreamPipeWriterTestBase.cs index 379db8da..b2e2be8f 100644 --- a/test/Nerdbank.Streams.Tests/StreamPipeWriterTestBase.cs +++ b/test/Nerdbank.Streams.Tests/StreamPipeWriterTestBase.cs @@ -7,7 +7,6 @@ using NSubstitute; using NSubstitute.ReceivedExtensions; using Xunit; -using Xunit.Abstractions; public abstract class StreamPipeWriterTestBase : TestBase { diff --git a/test/Nerdbank.Streams.Tests/StreamUsePipeReaderTests.cs b/test/Nerdbank.Streams.Tests/StreamUsePipeReaderTests.cs index c0153de3..63a1c4da 100644 --- a/test/Nerdbank.Streams.Tests/StreamUsePipeReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/StreamUsePipeReaderTests.cs @@ -7,7 +7,6 @@ using NSubstitute; using NSubstitute.ExceptionExtensions; using Xunit; -using Xunit.Abstractions; public class StreamUsePipeReaderTests : StreamPipeReaderTestBase { diff --git a/test/Nerdbank.Streams.Tests/StreamUsePipeWriterTests.cs b/test/Nerdbank.Streams.Tests/StreamUsePipeWriterTests.cs index 98f2ce3d..036c16a0 100644 --- a/test/Nerdbank.Streams.Tests/StreamUsePipeWriterTests.cs +++ b/test/Nerdbank.Streams.Tests/StreamUsePipeWriterTests.cs @@ -7,7 +7,6 @@ using NSubstitute; using NSubstitute.ExceptionExtensions; using Xunit; -using Xunit.Abstractions; public class StreamUsePipeWriterTests : StreamPipeWriterTestBase { diff --git a/test/Nerdbank.Streams.Tests/StreamUseStrictPipeReaderTests.cs b/test/Nerdbank.Streams.Tests/StreamUseStrictPipeReaderTests.cs index d5790daf..c137c661 100644 --- a/test/Nerdbank.Streams.Tests/StreamUseStrictPipeReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/StreamUseStrictPipeReaderTests.cs @@ -7,7 +7,6 @@ using NSubstitute; using NSubstitute.ExceptionExtensions; using Xunit; -using Xunit.Abstractions; [Obsolete("Tests functionality that .NET now exposes directly through PipeReader.Create(Stream)")] public class StreamUseStrictPipeReaderTests : StreamPipeReaderTestBase diff --git a/test/Nerdbank.Streams.Tests/StreamUseStrictPipeWriterTests.cs b/test/Nerdbank.Streams.Tests/StreamUseStrictPipeWriterTests.cs index c2541cac..0dc892a8 100644 --- a/test/Nerdbank.Streams.Tests/StreamUseStrictPipeWriterTests.cs +++ b/test/Nerdbank.Streams.Tests/StreamUseStrictPipeWriterTests.cs @@ -6,7 +6,6 @@ using NSubstitute; using NSubstitute.ExceptionExtensions; using Xunit; -using Xunit.Abstractions; [Obsolete("Tests functionality that .NET now exposes directly through PipeWriter.Create(Stream)")] public class StreamUseStrictPipeWriterTests : StreamPipeWriterTestBase diff --git a/test/Nerdbank.Streams.Tests/SubstreamTests.cs b/test/Nerdbank.Streams.Tests/SubstreamTests.cs index 464142fc..cd69488e 100644 --- a/test/Nerdbank.Streams.Tests/SubstreamTests.cs +++ b/test/Nerdbank.Streams.Tests/SubstreamTests.cs @@ -5,7 +5,6 @@ using Nerdbank.Streams; using NSubstitute; using Xunit; -using Xunit.Abstractions; public class SubstreamTests : TestBase { diff --git a/test/Nerdbank.Streams.Tests/TestBase.cs b/test/Nerdbank.Streams.Tests/TestBase.cs index 0fc31f70..ebfc269d 100644 --- a/test/Nerdbank.Streams.Tests/TestBase.cs +++ b/test/Nerdbank.Streams.Tests/TestBase.cs @@ -1,22 +1,17 @@ // Copyright (c) Andrew Arnott. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Buffers; using System.Diagnostics; -using System.IO; using System.IO.Pipelines; -using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; -using System.Threading; -using System.Threading.Tasks; using Microsoft; using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; +using Xunit.Sdk; public abstract class TestBase : IDisposable { @@ -207,7 +202,7 @@ internal Task ExecuteInIsolationAsync(string testClassName, string testMet #if NETFRAMEWORK if (IsMono) { - return Task.FromException(new SkipException("Test isolation is not yet supported on this mono.")); + return Task.FromException(SkipException.ForSkip("Test isolation is not yet supported on this mono.")); } const string testHostProcessName = "IsolatedTestHost.exe"; @@ -264,7 +259,7 @@ internal Task ExecuteInIsolationAsync(string testClassName, string testMet switch (t.Result) { case IsolatedTestHost.ExitCodes.TestSkipped: - throw new SkipException("Test skipped. See output of isolated task for details."); + throw SkipException.ForSkip("Test skipped. See output of isolated task for details."); case IsolatedTestHost.ExitCodes.TestPassed: default: Assert.Equal(IsolatedTestHost.ExitCodes.TestPassed, t.Result); @@ -275,7 +270,7 @@ internal Task ExecuteInIsolationAsync(string testClassName, string testMet }, TaskScheduler.Default); #else - return Task.FromException(new SkipException("Test isolation is not yet supported on this platform.")); + return Task.FromException(SkipException.ForSkip("Test isolation is not yet supported on this platform.")); #endif } @@ -470,6 +465,8 @@ private class FileLogger : ITestOutputHelper, IDisposable private readonly StreamWriter file; private readonly ITestOutputHelper forwardTo; + public string Output => throw new NotImplementedException(); + internal FileLogger(string fileName, ITestOutputHelper forwardTo) { this.file = new StreamWriter(File.OpenWrite(fileName)); @@ -491,5 +488,19 @@ public void WriteLine(string format, params object[] args) } public void Dispose() => this.file.Dispose(); + + public void Write(string message) + { + this.file.Write(message); + this.forwardTo.Write(message); + Debug.Write(message); + } + + public void Write(string format, params object[] args) + { + this.file.Write(format, args); + this.forwardTo.Write(format, args); + Debug.Write(string.Format(format, args)); + } } } diff --git a/test/Nerdbank.Streams.Tests/WebSocketStreamTests.cs b/test/Nerdbank.Streams.Tests/WebSocketStreamTests.cs index eef241f9..7de6c36e 100644 --- a/test/Nerdbank.Streams.Tests/WebSocketStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/WebSocketStreamTests.cs @@ -19,7 +19,6 @@ using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; using Xunit; -using Xunit.Abstractions; #pragma warning disable SA1414 // Tuple types in signatures should have element names diff --git a/test/Nerdbank.Streams.Tests/XunitTraceListener.cs b/test/Nerdbank.Streams.Tests/XunitTraceListener.cs index 6558b124..2215372c 100644 --- a/test/Nerdbank.Streams.Tests/XunitTraceListener.cs +++ b/test/Nerdbank.Streams.Tests/XunitTraceListener.cs @@ -5,7 +5,7 @@ using System.Buffers; using System.Diagnostics; using System.Text; -using Xunit.Abstractions; +using Xunit; internal class XunitTraceListener : TraceListener { From a7ae48e559f700d0155ae37d23300ede124a70fa Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 24 Dec 2024 07:32:14 -0700 Subject: [PATCH 11/12] Fix timeout token registration disposal This prevents a bunch of InvalidOperationExceptions from being thrown when a timeout is logged without an active test. --- test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs | 1 + .../MultiplexingStreamSeededChannelTests.cs | 2 ++ test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs | 2 ++ test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs | 6 +++++- test/Nerdbank.Streams.Tests/TestBase.cs | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs index 532aa926..5ffc60a8 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs @@ -42,6 +42,7 @@ public ValueTask DisposeAsync() { this.serverPipe.Dispose(); this.clientPipe.Dispose(); + this.Dispose(); return default; } diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs index 4665b069..99461aa0 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamSeededChannelTests.cs @@ -74,6 +74,8 @@ public async ValueTask DisposeAsync() this.mx1?.TraceSource.Listeners.OfType().SingleOrDefault()?.Dispose(); this.mx2?.TraceSource.Listeners.OfType().SingleOrDefault()?.Dispose(); + + this.Dispose(); } [Fact] diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs index 524e280c..a968bba1 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs @@ -49,6 +49,8 @@ public async ValueTask DisposeAsync() this.mx1?.TraceSource.Listeners.OfType().SingleOrDefault()?.Dispose(); this.mx2?.TraceSource.Listeners.OfType().SingleOrDefault()?.Dispose(); + + this.Dispose(); } [Fact, Obsolete] diff --git a/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs b/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs index dd4dd331..5f61aec7 100644 --- a/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs +++ b/test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs @@ -19,7 +19,11 @@ public NestedPipeReaderTests(ITestOutputHelper logger) { } - public ValueTask DisposeAsync() => default; + public ValueTask DisposeAsync() + { + this.Dispose(); + return default; + } public async ValueTask InitializeAsync() { diff --git a/test/Nerdbank.Streams.Tests/TestBase.cs b/test/Nerdbank.Streams.Tests/TestBase.cs index ebfc269d..592701b9 100644 --- a/test/Nerdbank.Streams.Tests/TestBase.cs +++ b/test/Nerdbank.Streams.Tests/TestBase.cs @@ -66,6 +66,7 @@ protected TestBase(ITestOutputHelper logger) public void Dispose() { + this.timeoutLoggerRegistration.Dispose(); this.Dispose(true); GC.SuppressFinalize(this); } From 60c3f3159dcdb9cabf1cfb8c3e4113395db1dcb6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 24 Dec 2024 07:47:50 -0700 Subject: [PATCH 12/12] Resolve remaining build warnings --- Directory.Packages.props | 2 +- test/.editorconfig | 3 +++ test/IsolatedTestHost/IsolatedTestHost.csproj | 2 +- test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs | 2 +- test/Nerdbank.Streams.Tests/TestBase.cs | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 121fe7ba..3432a30d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,13 +26,13 @@ + - diff --git a/test/.editorconfig b/test/.editorconfig index 4219bf2d..1c5cc9c1 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -59,3 +59,6 @@ dotnet_diagnostic.VSTHRD003.severity = silent # SA1611: Element parameters should be documented dotnet_diagnostic.SA1611.severity = silent + +# xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken +dotnet_diagnostic.xUnit1051.severity = suggestion diff --git a/test/IsolatedTestHost/IsolatedTestHost.csproj b/test/IsolatedTestHost/IsolatedTestHost.csproj index b740a645..535491f2 100644 --- a/test/IsolatedTestHost/IsolatedTestHost.csproj +++ b/test/IsolatedTestHost/IsolatedTestHost.csproj @@ -6,7 +6,7 @@ - + diff --git a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs index a968bba1..e84b0eca 100644 --- a/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs +++ b/test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs @@ -772,7 +772,7 @@ public async Task CancelChannelOfferBeforeAcceptance(bool cancelFirst) await Task.Delay(250); } - MultiplexingStream.Channel? acceptedChannel = await this.mx2.AcceptChannelAsync(string.Empty, ExpectedTimeoutToken).ConfigureAwait(false); + MultiplexingStream.Channel? acceptedChannel = await this.mx2.AcceptChannelAsync(string.Empty, ExpectedTimeoutToken); acceptedStream = acceptedChannel.AsStream(); // In this case, we accepted the channel before receiving the cancellation notice. The channel should be terminated by the remote side very soon. diff --git a/test/Nerdbank.Streams.Tests/TestBase.cs b/test/Nerdbank.Streams.Tests/TestBase.cs index 592701b9..68a1b03c 100644 --- a/test/Nerdbank.Streams.Tests/TestBase.cs +++ b/test/Nerdbank.Streams.Tests/TestBase.cs @@ -466,14 +466,14 @@ private class FileLogger : ITestOutputHelper, IDisposable private readonly StreamWriter file; private readonly ITestOutputHelper forwardTo; - public string Output => throw new NotImplementedException(); - internal FileLogger(string fileName, ITestOutputHelper forwardTo) { this.file = new StreamWriter(File.OpenWrite(fileName)); this.forwardTo = forwardTo; } + public string Output => throw new NotImplementedException(); + public void WriteLine(string message) { this.file.WriteLine(message);