avoid code duplication for disabling parallelization with xUnit (#62132)
authorAdam Sitnik <adam.sitnik@gmail.com>
Tue, 30 Nov 2021 14:52:48 +0000 (15:52 +0100)
committerGitHub <noreply@github.com>
Tue, 30 Nov 2021 14:52:48 +0000 (15:52 +0100)
The collection definitions must be in the same assembly as the test that uses them

41 files changed:
src/libraries/Common/tests/TestUtilities/System/DisableParallelization.cs [new file with mode: 0644]
src/libraries/System.ComponentModel.TypeConverter/tests/MemberDescriptorTests.cs
src/libraries/System.ComponentModel.TypeConverter/tests/ReflectionCachesUpdateHandlerTests.cs
src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj
src/libraries/System.ComponentModel.TypeConverter/tests/TypeDescriptorTests.cs
src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs
src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj
src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs
src/libraries/System.IO.FileSystem/tests/DisabledFileLockingTests/System.IO.FileSystem.DisabledFileLocking.Tests.csproj
src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_options.cs
src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2FlowControl.cs
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2KeepAlivePing.cs
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
src/libraries/System.Net.NameResolution/tests/FunctionalTests/LoggingTest.cs
src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj
src/libraries/System.Net.NameResolution/tests/FunctionalTests/TestSettings.cs
src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamConnectedStreamConformanceTests.cs
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs
src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj
src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/LocalEndPointTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SelectTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SendFile.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveNonParallel.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketTestHelper.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj
src/libraries/System.Net.Sockets/tests/FunctionalTests/TimeoutTest.cs
src/libraries/System.Runtime.Loader/tests/ApplyUpdateTest.cs
src/libraries/System.Runtime.Loader/tests/ApplyUpdateUtil.cs
src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj
src/libraries/System.Runtime/tests/Helpers.cs
src/libraries/System.Runtime/tests/NlsTests/System.Runtime.Nls.Tests.csproj
src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj
src/libraries/System.Runtime/tests/System/ArrayTests.cs
src/libraries/System.Runtime/tests/System/Reflection/ReflectionCacheTests.cs

diff --git a/src/libraries/Common/tests/TestUtilities/System/DisableParallelization.cs b/src/libraries/Common/tests/TestUtilities/System/DisableParallelization.cs
new file mode 100644 (file)
index 0000000..d82016e
--- /dev/null
@@ -0,0 +1,12 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Xunit;
+
+namespace System
+{
+    // The collection definitions must be in the same assembly as the test that uses them.
+    // So please use "Compile Include" in the project file to include this class.
+    [CollectionDefinition(nameof(DisableParallelization), DisableParallelization = true)]
+    public class DisableParallelization { }
+}
index 03fc458..651a485 100644 (file)
@@ -9,11 +9,8 @@ using Xunit;
 
 namespace System.ComponentModel.Tests
 {
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     // Mutable static comparision in the implementation
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public class MemberDescriptorTests
     {
         [Theory]
index 84a7069..2bf4e13 100644 (file)
@@ -7,7 +7,7 @@ using Xunit;
 namespace System.ComponentModel.Tests
 {
     [SimpleUpdateTest]
-    [Collection("NoParallelTests")] // Clears the cache which disrupts concurrent tests
+    [Collection(nameof(DisableParallelization))] // Clears the cache which disrupts concurrent tests
     public class ReflectionCachesUpdateHandlerTests
     {
         [Fact]
index c710dd0..61850c9 100644 (file)
     <Compile Include="Security\Authentication\ExtendedProtection\ExtendedProtectionPolicyTypeConverterTests.cs" />
     <Compile Include="XTypeDescriptionProviderTests.cs" />
 
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+        Link="Common\TestUtilities\System\DisableParallelization.cs" />
     <TrimmerRootDescriptor Include="$(ILLinkDescriptorsPath)ILLink.Descriptors.Castle.xml" />
   </ItemGroup>
   <ItemGroup>
index d175465..c148582 100644 (file)
@@ -10,7 +10,7 @@ using Xunit;
 
 namespace System.ComponentModel.Tests
 {
-    [Collection("NoParallelTests")] // manipulates cache
+    [Collection(nameof(DisableParallelization))] // manipulates cache
     public class TypeDescriptorTests
     {
         [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoAOT))] // Mock will try to JIT 
index 100aa44..1b343e5 100644 (file)
@@ -1086,7 +1086,7 @@ namespace System.IO.Tests
         }
     }
 
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public partial class DangerousFileSystemWatcherTests : FileSystemWatcherTest
     {
         private readonly ITestOutputHelper _output;
index 0fd7e9a..453021d 100644 (file)
@@ -35,6 +35,8 @@
              Link="Common\System\IO\TempFile.cs" />
     <Compile Include="$(CommonTestPath)System\IO\TempDirectory.cs"
              Link="Common\System\IO\TempDirectory.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+             Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsLinux)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
     <Compile Include="FileSystemWatcher.Unix.cs" />
index c40dcc5..f1b1487 100644 (file)
@@ -11,9 +11,6 @@ using Xunit.Abstractions;
 
 namespace System.IO.Tests
 {
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     public abstract partial class FileSystemWatcherTest : FileCleanupTestBase
     {
         // Events are reported asynchronously by the OS, so allow an amount of time for
index b9739cb..449a1c3 100644 (file)
@@ -20,6 +20,7 @@
     <Compile Include="..\PortedCommon\IOInputs.cs" />
     <Compile Include="..\PortedCommon\IOServices.cs" />
     <Compile Include="$(CommonTestPath)System\IO\PathFeatures.cs" Link="Common\System\IO\PathFeatures.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
     <Compile Remove="..\**\*.Windows.cs" />
index 3d3e2d0..6e694e4 100644 (file)
@@ -77,7 +77,7 @@ namespace System.IO.Tests
     }
 
     [PlatformSpecific(TestPlatforms.Windows)] // the test setup is Windows-specifc
-    [Collection("NoParallelTests")] // don't run in parallel, as file sharing logic is not thread-safe
+    [Collection(nameof(DisableParallelization))] // don't run in parallel, as file sharing logic is not thread-safe
     [OuterLoop("Requires admin privileges to create a file share")]
     [ConditionalClass(typeof(UncFilePathFileStreamStandaloneConformanceTests), nameof(CanShareFiles))]
     public class UncFilePathFileStreamStandaloneConformanceTests : UnbufferedAsyncFileStreamStandaloneConformanceTests
index c4344de..bbae2fb 100644 (file)
@@ -10,7 +10,7 @@ namespace System.IO.Tests
     // Don't run in parallel as the WhenDiskIsFullTheErrorMessageContainsAllDetails test
     // consumes entire available free space on the disk (only on Linux, this is how posix_fallocate works)
     // and if we try to run other disk-writing test in the meantime we are going to get "No space left on device" exception.
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public partial class FileStream_ctor_options : FileStream_ctor_str_fm_fa_fs_buffer_fo
     {
         protected override string GetExpectedParamName(string paramName) => "value";
@@ -166,7 +166,4 @@ namespace System.IO.Tests
             Assert.False(exists);
         }
     }
-
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
 }
index 5180426..476bf05 100644 (file)
     <Compile Include="$(CommonTestPath)System\IO\PathFeatures.cs" Link="Common\System\IO\PathFeatures.cs" />
     <Content Include="DirectoryInfo\test-dir\dummy.txt" Link="test-dir\dummy.txt" />
     <Compile Include="$(CommonPath)System\IO\PathInternal.CaseSensitivity.cs" Link="Common\System\IO\PathInternal.CaseSensitivity.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="$(CommonTestPath)StreamConformanceTests\StreamConformanceTests.csproj" />
index f284918..6b0e885 100644 (file)
@@ -11,16 +11,11 @@ using Xunit.Abstractions;
 
 namespace System.Net.Http.Functional.Tests
 {
-    [CollectionDefinition(nameof(NonParallelTestCollection), DisableParallelization = true)]
-    public class NonParallelTestCollection
-    {
-    }
-
     // This test class contains tests which are strongly timing-dependent.
     // There are two mitigations avoid flaky behavior on CI:
     // - Parallel test execution is disabled
     // - Using extreme parameters, and checks which are very unlikely to fail, if the implementation is correct
-    [Collection(nameof(NonParallelTestCollection))]
+    [Collection(nameof(DisableParallelization))]
     [ConditionalClass(typeof(SocketsHttpHandler_Http2FlowControl_Test), nameof(IsSupported))]
     public sealed class SocketsHttpHandler_Http2FlowControl_Test : HttpClientHandlerTestBase
     {
index aad7f5d..d760e8e 100644 (file)
@@ -13,7 +13,7 @@ using Xunit.Abstractions;
 
 namespace System.Net.Http.Functional.Tests
 {
-    [Collection(nameof(NonParallelTestCollection))]
+    [Collection(nameof(DisableParallelization))]
     [ConditionalClass(typeof(SocketsHttpHandler_Http2KeepAlivePing_Test), nameof(IsSupported))]
     public sealed class SocketsHttpHandler_Http2KeepAlivePing_Test : HttpClientHandlerTestBase
     {
index 14f444b..e7ce196 100644 (file)
@@ -3143,7 +3143,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_Http3_MsQuic : HttpClientHandlerTest_Http3
     {
         public SocketsHttpHandlerTest_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3151,7 +3151,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_Http3_Mock : HttpClientHandlerTest_Http3
     {
         public SocketsHttpHandlerTest_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3159,7 +3159,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_MsQuic : HttpClientHandlerTest
     {
         public SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3168,7 +3168,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_Mock : HttpClientHandlerTest
     {
         public SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3177,7 +3177,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_Cookies_Http3_MsQuic : HttpClientHandlerTest_Cookies
     {
         public SocketsHttpHandlerTest_Cookies_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3186,7 +3186,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_Cookies_Http3_Mock : HttpClientHandlerTest_Cookies
     {
         public SocketsHttpHandlerTest_Cookies_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3195,7 +3195,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_MsQuic : HttpClientHandlerTest_Headers
     {
         public SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3204,7 +3204,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_Mock : HttpClientHandlerTest_Headers
     {
         public SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3213,7 +3213,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_MsQuic : SocketsHttpHandler_Cancellation_Test
     {
         public SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3222,7 +3222,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_Mock : SocketsHttpHandler_Cancellation_Test
     {
         public SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3231,7 +3231,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_MsQuic : HttpClientHandler_AltSvc_Test
     {
         public SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3240,7 +3240,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_Mock : HttpClientHandler_AltSvc_Test
     {
         public SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3249,7 +3249,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_Finalization_Http3_MsQuic : HttpClientHandler_Finalization_Test
     {
         public SocketsHttpHandler_HttpClientHandler_Finalization_Http3_MsQuic(ITestOutputHelper output) : base(output) { }
@@ -3258,7 +3258,7 @@ namespace System.Net.Http.Functional.Tests
     }
 
     [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class SocketsHttpHandler_HttpClientHandler_Finalization_Http3_Mock : HttpClientHandler_Finalization_Test
     {
         public SocketsHttpHandler_HttpClientHandler_Finalization_Http3_Mock(ITestOutputHelper output) : base(output) { }
@@ -3266,10 +3266,6 @@ namespace System.Net.Http.Functional.Tests
         protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.Mock;
     }
 
-    // Define test collection for tests to avoid all other tests.
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))]
     public abstract class SocketsHttpHandler_RequestValidationTest
     {
index 343267d..d057f21 100644 (file)
              Link="Common\System\Net\Http\HttpClientHandlerTest.Cookies.cs" />
     <Compile Include="$(CommonTestPath)System\Net\Http\HttpClientHandlerTest.DefaultProxyCredentials.cs"
              Link="Common\System\Net\Http\HttpClientHandlerTest.DefaultProxyCredentials.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+             Link="Common\TestUtilities\System\DisableParallelization.cs" />
     <Compile Include="HttpClientHandlerTest.AltSvc.cs" />
     <Compile Include="SocketsHttpHandlerTest.Cancellation.cs" />
     <Compile Include="SocketsHttpHandlerTest.Http2FlowControl.cs" />
index 915067a..c333376 100644 (file)
@@ -13,7 +13,7 @@ namespace System.Net.NameResolution.Tests
 {
     using Configuration = System.Net.Test.Common.Configuration;
 
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public class LoggingTest
     {
         [Fact]
index 2f9dea9..982ca84 100644 (file)
@@ -24,5 +24,7 @@
              Link="Common\System\Net\Configuration.Sockets.cs" />
     <Compile Include="$(CommonTestPath)System\Diagnostics\Tracing\TestEventListener.cs"
              Link="Common\System\Diagnostics\Tracing\TestEventListener.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+             Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
 </Project>
index 49c1b0a..f4b45bf 100644 (file)
@@ -8,9 +8,6 @@ using Xunit.Abstractions;
 
 namespace System.Net.NameResolution.Tests
 {
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     internal static class TestSettings
     {
         // A hostname that will not exist in any DNS caches, forcing some I/O to lookup.
index 40ed3bf..18d8b90 100644 (file)
@@ -20,7 +20,7 @@ using Xunit.Abstractions;
 namespace System.Net.Quic.Tests
 {
     [ConditionalClass(typeof(QuicTestBase<MsQuicProviderFactory>), nameof(IsSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public class MsQuicTests : QuicTestBase<MsQuicProviderFactory>
     {
         private static byte[] s_data = Encoding.UTF8.GetBytes("Hello world!");
index 271ca17..9856f5c 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Net.Quic.Tests
     }
 
     [ConditionalClass(typeof(QuicTestBase<MsQuicProviderFactory>), nameof(QuicTestBase<MsQuicProviderFactory>.IsSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class MsQuicQuicStreamConformanceTests : QuicStreamConformanceTests
     {
         protected override QuicImplementationProvider Provider => QuicImplementationProviders.MsQuic;
index 5fb1bc1..d2551ab 100644 (file)
@@ -994,13 +994,9 @@ namespace System.Net.Quic.Tests
     }
 
     [ConditionalClass(typeof(QuicTestBase<MsQuicProviderFactory>), nameof(QuicTestBase<MsQuicProviderFactory>.IsSupported))]
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public sealed class QuicStreamTests_MsQuicProvider : QuicStreamTests<MsQuicProviderFactory>
     {
         public QuicStreamTests_MsQuicProvider(ITestOutputHelper output) : base(output) { }
     }
-
-    // Define test collection for tests to avoid all other tests.
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
 }
index 2a17894..471ca7e 100644 (file)
@@ -22,6 +22,7 @@
     <Compile Include="$(CommonTestPath)System\Security\Cryptography\X509Certificates\CertificateAuthority.cs" Link="CommonTest\System\Security\Cryptography\X509Certificates\CertificateAuthority.cs" />
     <Compile Include="$(CommonTestPath)System\Security\Cryptography\X509Certificates\RevocationResponder.cs" Link="CommonTest\System\Security\Cryptography\X509Certificates\RevocationResponder.cs" />
     <Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs" Link="TestCommon\System\Threading\Tasks\TaskTimeoutExtensions.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" />
     <Compile Include="..\..\..\System.Net.Security\tests\FunctionalTests\TestHelper.cs" />
   </ItemGroup>
   <ItemGroup>
index 5f11eaa..39506ce 100644 (file)
@@ -364,7 +364,7 @@ namespace System.Net.Sockets.Tests
     // The test class is declared non-parallel because of possible IPv4/IPv6 port-collision on Unix:
     // When running these tests in parallel with other tests, there is some chance that the DualMode client
     // will connect to an IPv4 server of a parallel test case.
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public abstract class Connect_NonParallel<T> : SocketTestHelperBase<T> where T : SocketHelperBase, new()
     {
         protected Connect_NonParallel(ITestOutputHelper output) : base(output)
index c839493..06d1ca4 100644 (file)
@@ -764,7 +764,7 @@ namespace System.Net.Sockets.Tests
         }
     }
 
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public class DisposedSocketTestsNonParallel
     {
         [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsPreciseGcSupported))]
index 09f198c..9fb542d 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Net.Sockets.Tests
     // When running in parallel with other tests, there is some chance that Accept() calls in LocalEndPointTest will
     // accept a connection request from another, DualMode client living in a parallel test
     // that is intended to connect to a server of opposite AddressFamily in the parallel test.
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public abstract class LocalEndPointTest<T> : SocketTestHelperBase<T> where T : SocketHelperBase, new()
     {
         protected abstract bool IPv6 { get; }
index f85a9b0..0b49749 100644 (file)
@@ -277,7 +277,7 @@ namespace System.Net.Sockets.Tests
         }
     }
 
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public class SelectTest_NonParallel
     {
         [OuterLoop]
index aa0d967..35b427e 100644 (file)
@@ -467,7 +467,7 @@ namespace System.Net.Sockets.Tests
 
     // Running all cases of GreaterThan2GBFile_SendsAllBytes in parallel may attempt to allocate Min(ProcessorCount, Subclass_Count) * 2GB of disk space
     // in extreme cases. Some CI machines may run out of disk space if this happens.
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public abstract class SendFile_NonParallel<T> : SocketTestHelperBase<T> where T : SocketHelperBase, new()
     {
         protected SendFile_NonParallel(ITestOutputHelper output) : base(output)
index 470472f..97cad85 100644 (file)
@@ -10,7 +10,7 @@ using Xunit.Abstractions;
 
 namespace System.Net.Sockets.Tests
 {
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public abstract class SendReceiveNonParallel<T> : SocketTestHelperBase<T> where T : SocketHelperBase, new()
     {
         public SendReceiveNonParallel(ITestOutputHelper output) : base(output) { }
index 5073f60..0bf9bdd 100644 (file)
@@ -690,9 +690,9 @@ namespace System.Net.Sockets.Tests
         private static int SOL_SOCKET = OperatingSystem.IsLinux() ? 1 : (int)SocketOptionLevel.Socket;
     }
 
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     // Set of tests to not run  together with any other tests.
-    public partial class NoParallelTests
+    public class NoParallelTests
     {
         [Fact]
         public void BindDuringTcpWait_Succeeds()
@@ -714,7 +714,7 @@ namespace System.Net.Sockets.Tests
             }
 
             // Bind a socket to the same address we just used.
-            // To avoid conflict with other tests, this is part of the NoParallelTests test collection.
+            // To avoid conflict with other tests, this is part of the DisableParallelization test collection.
             using (Socket b = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
             {
                 b.Bind(new IPEndPoint(IPAddress.Loopback, port));
index e3bfff0..1922d37 100644 (file)
@@ -11,10 +11,6 @@ using Xunit.Abstractions;
 
 namespace System.Net.Sockets.Tests
 {
-    // Define test collection for tests to avoid all other tests.
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     // Abstract base class for various different socket "modes" (sync, async, etc)
     // See SendReceive.cs for usage
     public abstract class SocketHelperBase
index dbb949b..63e0987 100644 (file)
@@ -97,6 +97,8 @@
     <Compile Include="$(CommonPath)System\Net\Logging\NetEventSource.Common.cs"
              Link="Common\System\Net\Logging\NetEventSource.Common.cs" />
     <Compile Include="$(CommonTestPath)System\IO\TempFile.cs" Link="Common\System\IO\TempFile.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+             Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="$(CommonTestPath)StreamConformanceTests\StreamConformanceTests.csproj" />
index 91e2272..a442af6 100644 (file)
@@ -6,7 +6,7 @@ using Xunit;
 
 namespace System.Net.Sockets.Tests
 {
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public class TimeoutTest
     {
         [Fact]
index a582e3f..dd5c49c 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Reflection.Metadata
     /// script that applies one or more updates to Foo.dll The ApplyUpdateTest
     /// testsuite runs each test in sequence, loading the corresponding
     /// assembly, applying an update to it and observing the results.
-    [Collection(nameof(ApplyUpdateUtil.NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public class ApplyUpdateTest
     {
         [ConditionalFact(typeof(ApplyUpdateUtil), nameof (ApplyUpdateUtil.IsSupported))]
index 36d04c4..beaa4a0 100644 (file)
@@ -12,9 +12,6 @@ namespace System.Reflection.Metadata
         internal const string DotNetModifiableAssembliesSwitch = "DOTNET_MODIFIABLE_ASSEMBLIES";
         internal const string DotNetModifiableAssembliesValue = "debug";
 
-        [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-        public class NoParallelTests { }
-
         /// Whether ApplyUpdate is supported by the environment, test configuration, and runtime.
         ///
         /// We need:
index 2ecf08c..8c95424 100644 (file)
@@ -20,6 +20,7 @@
     <Compile Include="ResourceAssemblyLoadContext.cs" />
     <Compile Include="SatelliteAssemblies.cs" />
     <Compile Include="LoaderLinkTest.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" />
     <EmbeddedResource Include="MainStrings*.resx" />
   </ItemGroup>
   <ItemGroup>
index b44d82c..5d44dc6 100644 (file)
@@ -10,9 +10,6 @@ using Xunit.Abstractions;
 
 namespace System.Tests
 {
-    [CollectionDefinition("NoParallelTests", DisableParallelization = true)]
-    public partial class NoParallelTests { }
-
     public static class Helpers
     {
         private static Type s_refEmitType;
index b7d75d9..5c5e951 100644 (file)
@@ -39,6 +39,8 @@
              Link="Common\System\MockType.cs" />
     <Compile Include="$(CommonTestPath)Tests\System\StringTests.cs"
              Link="Common\System\StringTests.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
+             Link="Common\TestUtilities\System\DisableParallelization.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="$(CommonTestPath)TestUtilities.Unicode\TestUtilities.Unicode.csproj" />
index 734e649..45a57bd 100644 (file)
@@ -27,6 +27,7 @@
     <Compile Include="$(CommonTestPath)System\Collections\IList.NonGeneric.Tests.cs" Link="Common\System\Collections\IList.NonGeneric.Tests.cs" />
     <Compile Include="$(CommonTestPath)System\Collections\ICollection.NonGeneric.Tests.cs" Link="Common\System\Collections\ICollection.NonGeneric.Tests.cs" />
     <Compile Include="$(CommonTestPath)System\Collections\IEnumerable.NonGeneric.Tests.cs" Link="Common\System\Collections\IEnumerable.NonGeneric.Tests.cs" />
+    <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" />
     <Compile Include="Helpers.cs" />
     <Compile Include="Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs" />
     <Compile Include="Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs" />
index b7bdc5f..e0108b8 100644 (file)
@@ -4736,7 +4736,7 @@ namespace System.Tests
         public enum Int64Enum : long { }
     }
 
-    [Collection("NoParallelTests")]
+    [Collection(nameof(DisableParallelization))]
     public class DangerousArrayTests
     {
         [OuterLoop] // Allocates large array
index e976da0..a74262a 100644 (file)
@@ -6,7 +6,7 @@ using Xunit;
 
 namespace System.Reflection.Tests
 {
-    [Collection(nameof(NoParallelTests))]
+    [Collection(nameof(DisableParallelization))]
     public class ReflectionCacheTests
     {
         [Fact]