From 4166fbe8d0989b0a4ab60cec75a7fe48c98d3d75 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Sun, 11 Jan 2026 18:27:39 -0800 Subject: [PATCH] fix: prevent flaky tests by disabling parallel execution for registry tests Tests using CommandMetadataRegistry share static state and were failing intermittently when run in parallel. Added [Collection("MetadataRegistry")] attribute to all test classes that interact with the registry to ensure they run sequentially. Affected test classes: - CommandMetadataRegistryTests - ConventionAotPathTests - MetadataProviderTests - RemainingArgsPropertyConventionTests Co-Authored-By: Claude Opus 4.5 --- .../RemainingArgsPropertyConventionTests.cs | 2 ++ .../SourceGeneration/CommandMetadataRegistryTests.cs | 2 ++ .../SourceGeneration/ConventionAotPathTests.cs | 2 ++ .../SourceGeneration/MetadataProviderTests.cs | 2 ++ 4 files changed, 8 insertions(+) diff --git a/test/CommandLineUtils.Tests/RemainingArgsPropertyConventionTests.cs b/test/CommandLineUtils.Tests/RemainingArgsPropertyConventionTests.cs index fda30b1d..afe16c4a 100644 --- a/test/CommandLineUtils.Tests/RemainingArgsPropertyConventionTests.cs +++ b/test/CommandLineUtils.Tests/RemainingArgsPropertyConventionTests.cs @@ -10,6 +10,8 @@ namespace McMaster.Extensions.CommandLineUtils.Tests { + // Uses shared static CommandMetadataRegistry - must not run in parallel with other registry tests + [Collection("MetadataRegistry")] public class RemainingArgsPropertyConventionTests : ConventionTestBase { public RemainingArgsPropertyConventionTests(ITestOutputHelper output) : base(output) diff --git a/test/CommandLineUtils.Tests/SourceGeneration/CommandMetadataRegistryTests.cs b/test/CommandLineUtils.Tests/SourceGeneration/CommandMetadataRegistryTests.cs index ecdea865..1e40f1fc 100644 --- a/test/CommandLineUtils.Tests/SourceGeneration/CommandMetadataRegistryTests.cs +++ b/test/CommandLineUtils.Tests/SourceGeneration/CommandMetadataRegistryTests.cs @@ -8,6 +8,8 @@ namespace McMaster.Extensions.CommandLineUtils.Tests.SourceGeneration { + // Uses shared static CommandMetadataRegistry - must not run in parallel with other registry tests + [Collection("MetadataRegistry")] public class CommandMetadataRegistryTests { [Command(Name = "test1")] diff --git a/test/CommandLineUtils.Tests/SourceGeneration/ConventionAotPathTests.cs b/test/CommandLineUtils.Tests/SourceGeneration/ConventionAotPathTests.cs index 62b72e78..bfece719 100644 --- a/test/CommandLineUtils.Tests/SourceGeneration/ConventionAotPathTests.cs +++ b/test/CommandLineUtils.Tests/SourceGeneration/ConventionAotPathTests.cs @@ -14,6 +14,8 @@ namespace McMaster.Extensions.CommandLineUtils.Tests.SourceGeneration /// Tests for the AOT-friendly code paths in conventions. /// These tests exercise the generated metadata paths in conventions. /// + // Uses shared static CommandMetadataRegistry - must not run in parallel with other registry tests + [Collection("MetadataRegistry")] public class ConventionAotPathTests : IDisposable { public ConventionAotPathTests() diff --git a/test/CommandLineUtils.Tests/SourceGeneration/MetadataProviderTests.cs b/test/CommandLineUtils.Tests/SourceGeneration/MetadataProviderTests.cs index 2219bcee..fdfcdc46 100644 --- a/test/CommandLineUtils.Tests/SourceGeneration/MetadataProviderTests.cs +++ b/test/CommandLineUtils.Tests/SourceGeneration/MetadataProviderTests.cs @@ -8,6 +8,8 @@ namespace McMaster.Extensions.CommandLineUtils.Tests.SourceGeneration { + // Uses shared static CommandMetadataRegistry - must not run in parallel with other registry tests + [Collection("MetadataRegistry")] public class MetadataProviderTests { [Command(Name = "test", Description = "A test command")]