From 0bfbc424854e852088cbf036bdacee386e6ed26e Mon Sep 17 00:00:00 2001 From: Widthdom Date: Fri, 24 Jul 2026 23:55:45 +0900 Subject: [PATCH 1/2] Fix console-sensitive test isolation (#4798) --- TESTING_GUIDE.md | 12 ++++++------ changelog.d/unreleased/4798.fixed.md | 17 +++++++++++++++++ tests/CodeIndex.Tests/ConsoleCaptureTests.cs | 9 ++++++++- tests/CodeIndex.Tests/TestConsoleLock.cs | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 changelog.d/unreleased/4798.fixed.md diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index e163eb959..47756c6eb 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -25,7 +25,7 @@ Use the full suite by default. Use targeted filters only while iterating locally - Common direct test-only packages: `Microsoft.NET.Test.Sdk`, `xunit`, `xunit.runner.visualstudio`, `coverlet.collector`, `Microsoft.Data.Sqlite`, `FsCheck.Xunit` - These test-only packages are separate from the production dependency rule in `src/CodeIndex`, which still allows only `Microsoft.Data.Sqlite` at runtime. - `FsCheck.Xunit` is reserved for property-based tests that assert universal invariants (never-throws contracts, idempotence, "output is parseable by downstream consumer") across randomly generated inputs. Use it to complement, not replace, the example-based `[Fact]` / `[Theory]` tests — pick FsCheck when the property is a universally quantified claim, and an example test when a specific concrete case is the contract. -- Test parallelism: enabled by default across independent test classes. Tests that touch process-global state such as SQLite pool resets, environment variables, or current-directory overrides must use an explicit non-parallel collection. Console-sensitive classes share one xUnit collection so they remain serial with each other, but the collection may run beside independent classes; use `ConsoleCapture` for ordinary capture and keep every direct `Console.Out` / `Console.Error` swap under `TestConsoleLock.Gate`. That gate aliases the production `ConsoleStreamOwnership` gate so console synchronization and scoped production redirects cannot retain a test writer after its capture ends. +- Test parallelism: enabled by default across independent test classes. Tests that touch process-global state such as SQLite pool resets, environment variables, or current-directory overrides must use an explicit non-parallel collection. Console-sensitive classes share one non-parallel xUnit collection, so they remain serial with each other and do not run beside independent classes that may write request-id or global diagnostics to the process console. Use `ConsoleCapture` for ordinary capture and keep every direct `Console.Out` / `Console.Error` swap under `TestConsoleLock.Gate`. That gate aliases the production `ConsoleStreamOwnership` gate so console synchronization and scoped production redirects cannot retain a test writer after its capture ends. - Markdown unused-audit coverage indexes one real Markdown fixture containing common backtick and tilde fence-language markers. Keep default suppression, `documentation_surface` totals, reason tags, and `--all` recovery in that shared fixture. - Full-scan CLI and MCP no-op coverage treats one repository-wide reusable-stat snapshot read and one folded-readiness verification as performance contracts. Keep assertions for one snapshot read, one stat lookup per candidate, one folded verification, and no content load for unchanged files when changing incremental indexing. - Reference-graph refresh coverage treats graph-neutral indexing as a performance contract across incremental full scan, scoped `--files` update, and MCP indexing. Keep zero-refresh assertions for new and modified source files without symbols/references, plus a single batched refresh assertion when existing or new graph identity rows change. A healthy incremental generation must restrict identity/candidate/recursion work to transaction-committed dirty files, old and new `(language, folded name)` dependencies, and their old/new reciprocal edges; retain C#/Python language-transition and unchanged-target parity with a subsequent full refresh, rolled-back file batches, cancellation/retry, orphan-candidate cleanup, and the controlled 4,100-of-4,100 broad-scope fallback. Fresh/rebuild runs, missing identity contracts, and dirty sets of at least 4,096 references covering at least 50% of the graph must keep the full-refresh path. Query-plan coverage must keep all four scoped update phases and all ten candidate inserts on dirty-table-driven reference primary-key seeks, keep C# instantiate grouping on lookup names plus `idx_symbols_name_folded`, and prove that a sub-4,096 dirty set does not count the whole reference table without an explicit diagnostic hook. @@ -638,14 +638,14 @@ Use the inventory below before adding or moving a test class: - Environment variables: use `EnvironmentVariableScope.Capture(...)` so setup failures and assertion failures restore the original values through one cleanup path. - JSON API-version utility coverage belongs in the non-parallel collection because its combined command scenario temporarily disables update checks through a process-global environment variable; console locking alone does not isolate that lifetime. - `Console.Out` or `Console.Error` replacement: prefer `ConsoleCapture`, which owns the shared gate and checks the restored writer identity. If a specialized fixture must swap a writer directly, lock `TestConsoleLock.Gate` around the whole capture/swap window, restore in `finally`, and restore before disposing the captured writer. -- Console-only test classes do not need the SQLite-sensitive non-parallel collection once every capture/swap window, including writer-disposal checks, is protected by `ConsoleCapture` or `TestConsoleLock.Gate`. +- Console-only test classes belong in the dedicated non-parallel console-sensitive collection once every capture/swap window, including writer-disposal checks, is protected by `ConsoleCapture` or `TestConsoleLock.Gate`; they do not also need the SQLite-sensitive collection. - Pure i18n resolution, self-locking JSON-envelope capture, and isolated LSP request/budget fixtures should remain outside the SQLite-sensitive collection; owning a temporary DB is not itself process-global state when the context is disposed before helper cleanup. - LSP telemetry fixtures scope captured activities to an ambient parent trace so unrelated parallel requests cannot enter their assertions. The external-WAL snapshot fixture keeps its writer open through the before/after artifact comparison, then disposes its readers and writers before resilient project cleanup; it must not reintroduce process-wide pool resets. - Reader issue fixtures with per-instance DB ownership and external-process fixtures with per-instance directories are likewise parallel-safe when their `Dispose` paths release those resources through the shared helpers. - Schema-constraint fixtures dispose every `DbContext`, connection, command, and reader before directory cleanup; do not add unconditional pool resets that serialize these independent schema checks. - SQLite connection-string and command-policy tests are parallel-safe when every in-memory connection and command is instance-owned and disposed; referencing `Microsoft.Data.Sqlite` alone is not a reason to join the SQLite-sensitive collection. - Cross-platform path matrices can run in parallel when cache seeding is guarded by `PathCasingTestLock` and every filesystem/git fixture owns a unique temporary workspace. -- Exception-formatting contract tests should guard their shared console helper with `TestConsoleLock` and remain parallelizable; their in-memory SQLite retry probes do not mutate the process pool. +- Exception-formatting contract tests that capture process console output should use the console-sensitive collection and guard their shared helper with `TestConsoleLock`; their in-memory SQLite retry probes do not require the SQLite-sensitive collection. - Split pure pre-cancelled import and bounded-stream checks from import-replacement fixtures that mutate test-only hooks. Keep the pre-cancelled import fixture in the console-sensitive collection because empty stderr is part of its contract, and pin that assignment with a reflection contract so it cannot drift on either target framework. The bounded-stream fixture remains parallel-safe, while only the hook-owning class needs SQLite-sensitive serialization. - Release workflow and package-normalizer tests can run outside the SQLite-sensitive collection: xUnit keeps methods in their single class sequential, so its two scoped durability-hook probes cannot overlap each other. - Database-diff fixtures own independent left/right projects, lock console capture, and keep their sole row-budget override within the same sequential xUnit class; they do not require process-wide SQLite serialization. @@ -867,7 +867,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests" - 主な直接参照の test-only package: `Microsoft.NET.Test.Sdk`、`xunit`、`xunit.runner.visualstudio`、`coverlet.collector`、`Microsoft.Data.Sqlite`、`FsCheck.Xunit` - これらの test-only package は `src/CodeIndex` の本番依存ルールとは別であり、runtime 側は引き続き `Microsoft.Data.Sqlite` のみを許容する。 - `FsCheck.Xunit` はランダム生成入力に対する普遍的不変条件(never-throws、idempotence、"出力が downstream consumer で parse 可能" 等)を表明する property-based テスト専用です。例ベースの `[Fact]` / `[Theory]` を置き換えるのではなく補完するもので、普遍量化された主張なら FsCheck、特定の具体ケースが契約なら例ベースという形で使い分けてください。 -- テスト並列実行: 独立したテストクラス間ではデフォルトで有効です。SQLite pool の解放、環境変数の変更、カレントディレクトリの上書きのような process-global 状態を触るテストは、明示的な non-parallel collection に入れてください。console-sensitive class は同じ xUnit collection 内で互いに直列実行しますが、独立 class とは並列に実行できます。通常の capture には `ConsoleCapture` を使い、`Console.Out` / `Console.Error` を直接差し替える場合は `TestConsoleLock.Gate` で保護してください。この gate は本番の `ConsoleStreamOwnership` gate と同一なので、console 同期処理や scoped redirect が capture 終了後も test writer を保持することを防ぎます。 +- テスト並列実行: 独立したテストクラス間ではデフォルトで有効です。SQLite pool の解放、環境変数の変更、カレントディレクトリの上書きのような process-global 状態を触るテストは、明示的な non-parallel collection に入れてください。console-sensitive class は同じ non-parallel な xUnit collection を共有するため、互いに直列実行され、request-id や global diagnostics を process console へ書く可能性がある独立 class とも並列実行されません。通常の capture には `ConsoleCapture` を使い、`Console.Out` / `Console.Error` を直接差し替える場合は `TestConsoleLock.Gate` で保護してください。この gate は本番の `ConsoleStreamOwnership` gate と同一なので、console 同期処理や scoped redirect が capture 終了後も test writer を保持することを防ぎます。 - Markdown の unused audit coverage は、一般的な backtick / tilde fence の language marker を含む実 Markdown fixture を1回 index します。同じ fixture で既定抑制、`documentation_surface` totals、reason tag、`--all` による復元を維持してください。 - full-scan CLI と MCP の no-op coverage は、リポジトリ全体の reusable-stat snapshot read と folded-readiness verification がそれぞれ 1 回であることを performance contract とします。incremental indexing を変更するときは、snapshot read が 1 回、候補ごとの stat lookup が 1 回、folded verification が 1 回、unchanged file の content load が 0 回という assertion を維持してください。 - reference-graph refresh coverage は、incremental full scan、scoped `--files` update、MCP indexing を横断する graph-neutral indexing を performance contract とします。symbol/reference を持たない新規・変更 source file では refresh 0 回を維持し、既存または新規の graph identity 行が変化する場合は batch 全体で refresh 1 回を assertion してください。健全な incremental generation では identity / candidate / recursion 処理を transaction commit 済みの dirty file、旧・新の `(language, folded name)` 依存、旧・新の逆辺に限定します。C# / Python の言語遷移、未変更targetを参照する新規callerと後続full refreshのparity、rollback file batch、cancel後retry、孤立candidate cleanup、4,100件中4,100件をdirtyにする制御broad-scope fallbackを維持してください。fresh/rebuild、identity契約欠落、または4,096件以上かつgraphの50%以上を占めるdirty集合ではfull-refresh経路を維持します。query-plan coverageでは、scoped updateの4 phaseとcandidate INSERT 10本をdirty table起点のreference主キーseekに保ち、C# instantiate groupingをlookup nameと`idx_symbols_name_folded`起点にし、明示的なdiagnostic hookがない4,096件未満のdirty集合ではreference table全件COUNTを行わないことを検証してください。 @@ -1475,14 +1475,14 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests" - 環境変数: `EnvironmentVariableScope.Capture(...)` を使い、setup failure や assertion failure でも単一の cleanup 経路で元の値に戻す。 - JSON API-versionのutility coverageは、combined command scenarioがprocess-globalな環境変数でupdate checkを一時無効化するためnon-parallel collectionに置きます。console lockだけではそのlifetimeを分離できません。 - `Console.Out` / `Console.Error` の差し替え: shared gate の所有と復元writerの同一性確認を行う `ConsoleCapture` を優先する。特殊なfixtureで直接差し替える必要がある場合は、capture / swap 期間全体を `TestConsoleLock.Gate` で lockし、`finally`で復元し、capture writerをdisposeする前に元writerへ戻す。 -- console だけを扱う test class は、writer disposal check を含むすべての capture / swap 期間が `ConsoleCapture` または `TestConsoleLock.Gate` で保護されていれば、SQLite-sensitive non-parallel collection に入れる必要はない。 +- console だけを扱う test class は、writer disposal check を含むすべての capture / swap 期間を `ConsoleCapture` または `TestConsoleLock.Gate` で保護したうえで、専用の non-parallel な console-sensitive collection に入れる。SQLite-sensitive collection にも入れる必要はない。 - pure i18n resolution、内部で lock する JSON-envelope capture、独立した LSP request / budget fixture は SQLite-sensitive collection の外に保つ。一時 DB を所有するだけなら、context を helper cleanup 前に dispose している限り process-global state ではない。 - LSP telemetry fixture は capture した activity を ambient parent trace に限定し、無関係な parallel request が assertion に入らないようにする。external-WAL snapshot fixture は before / after の artifact 比較が終わるまで writer を開いたままにし、その後 resilient な project cleanup 前に reader / writer を dispose する。process-wide pool reset を再導入しないこと。 - instance ごとに DB を所有する reader issue fixture と、instance ごとに directory を所有する external-process fixture も、`Dispose` で共有 helper を通して resource を解放する限り parallel-safe である。 - schema-constraint fixture は directory cleanup 前にすべての `DbContext`、connection、command、reader を dispose する。独立した schema check を直列化する無条件 pool reset を追加しないこと。 - SQLite connection-string / command-policy test は、各 in-memory connection と command を test instance が所有して dispose する限り parallel-safe である。`Microsoft.Data.Sqlite` を参照するだけでは SQLite-sensitive collection に入れる理由にならない。 - cross-platform path matrix は、cache seed を `PathCasingTestLock` で保護し、各 filesystem / git fixture が一意な temporary workspace を所有する限り parallel 実行できる。 -- exception-formatting contract test は共有 console helper を `TestConsoleLock` で保護して parallel 実行可能に保つ。in-memory SQLite retry probe は process pool を変更しない。 +- process console output を capture する exception-formatting contract test は console-sensitive collection を使い、共有 console helper を `TestConsoleLock` で保護する。in-memory SQLite retry probe のために SQLite-sensitive collection へ入れる必要はない。 - pure な事前 cancellation import / bounded-stream check は test-only hook を変更する import replacement fixture から分離する。空の stderr が契約の一部であるため、事前 cancellation import fixture は console-sensitive collection に保ち、どちらの target framework でもこの割当てが drift しないよう reflection contract で固定する。bounded-stream fixture は parallel-safe なままとして、SQLite-sensitive な直列化は hook を所有する class だけに限定する。 - release workflow / package-normalizer test は SQLite-sensitive collection の外で実行できる。xUnit は単一 class 内の method を直列に保つため、scope された2件の durability-hook probe は互いに重ならない。 - database diff fixture は独立した left / right project を所有し、console capture を lock し、唯一の row-budget override を同じ xUnit class の直列実行内に閉じるため、process-wide な SQLite 直列化は不要である。 diff --git a/changelog.d/unreleased/4798.fixed.md b/changelog.d/unreleased/4798.fixed.md new file mode 100644 index 000000000..bcddf4fae --- /dev/null +++ b/changelog.d/unreleased/4798.fixed.md @@ -0,0 +1,17 @@ +--- +category: fixed +issues: + - 4798 +affected: + - tests/CodeIndex.Tests/TestConsoleLock.cs + - tests/CodeIndex.Tests/ConsoleCaptureTests.cs + - TESTING_GUIDE.md +--- + +## English + +- **Console-sensitive tests no longer capture concurrent request-id logs (#4798)** — the shared console-sensitive xUnit collection is now non-parallel, preventing MCP request-id and global diagnostic lines from unrelated tests from entering captured stdout or stderr. + +## 日本語 + +- **console-sensitive test が並行実行された request-id log を取り込まないようになりました (#4798)** — 共有の console-sensitive xUnit collection を non-parallel にし、無関係なテストの MCP request-id や global diagnostic 行が capture 中の stdout / stderr に混入することを防ぎます。 diff --git a/tests/CodeIndex.Tests/ConsoleCaptureTests.cs b/tests/CodeIndex.Tests/ConsoleCaptureTests.cs index 15b587253..3ea65edff 100644 --- a/tests/CodeIndex.Tests/ConsoleCaptureTests.cs +++ b/tests/CodeIndex.Tests/ConsoleCaptureTests.cs @@ -6,14 +6,21 @@ namespace CodeIndex.Tests; public class ConsoleCaptureTests { [Fact] - public void ImportCancellationFixture_UsesConsoleSensitiveCollection_Issue4650() + public void ConsoleSensitiveCollection_AssignsImportCancellationAndDisablesParallelization_Issues4650_4798() { var attribute = Assert.Single( typeof(ExportImportCommandRunnerCancellationTests).CustomAttributes, static candidate => candidate.AttributeType == typeof(CollectionAttribute)); var collectionName = Assert.Single(attribute.ConstructorArguments); + var definition = Assert.Single( + typeof(ConsoleSensitiveCollection).CustomAttributes, + static candidate => candidate.AttributeType == typeof(CollectionDefinitionAttribute)); + var disableParallelization = Assert.Single( + definition.NamedArguments, + static candidate => candidate.MemberName == nameof(CollectionDefinitionAttribute.DisableParallelization)); Assert.Equal("Console sensitive", collectionName.Value); + Assert.True(Assert.IsType(disableParallelization.TypedValue.Value)); } [Fact] diff --git a/tests/CodeIndex.Tests/TestConsoleLock.cs b/tests/CodeIndex.Tests/TestConsoleLock.cs index 997adc6f4..1a79dd50c 100644 --- a/tests/CodeIndex.Tests/TestConsoleLock.cs +++ b/tests/CodeIndex.Tests/TestConsoleLock.cs @@ -3,7 +3,7 @@ namespace CodeIndex.Tests; -[CollectionDefinition("Console sensitive")] +[CollectionDefinition("Console sensitive", DisableParallelization = true)] public sealed class ConsoleSensitiveCollection { } From fd22d397c5b999871a1058a29623ec03f45b4eda Mon Sep 17 00:00:00 2001 From: Widthdom Date: Sat, 25 Jul 2026 01:04:27 +0900 Subject: [PATCH 2/2] Cover all global console capture tests (#4798) --- changelog.d/unreleased/4798.fixed.md | 12 ++++++-- tests/CodeIndex.Tests/AuditLogSinkTests.cs | 1 + tests/CodeIndex.Tests/CliFlagSchemaTests.cs | 1 + .../CommandErrorWriterTests.cs | 1 + tests/CodeIndex.Tests/ConsoleCaptureTests.cs | 29 +++++++++++++++---- .../DiffCommandHelpersTests.cs | 1 + tests/CodeIndex.Tests/LicensePolicyTests.cs | 1 + tests/CodeIndex.Tests/ProgramCliTests.cs | 1 + tests/CodeIndex.Tests/SymbolExtractorTests.cs | 1 + tests/CodeIndex.Tests/TestTelemetryTests.cs | 1 + 10 files changed, 41 insertions(+), 8 deletions(-) diff --git a/changelog.d/unreleased/4798.fixed.md b/changelog.d/unreleased/4798.fixed.md index bcddf4fae..8f5abbdeb 100644 --- a/changelog.d/unreleased/4798.fixed.md +++ b/changelog.d/unreleased/4798.fixed.md @@ -3,15 +3,23 @@ category: fixed issues: - 4798 affected: + - tests/CodeIndex.Tests/AuditLogSinkTests.cs + - tests/CodeIndex.Tests/CliFlagSchemaTests.cs + - tests/CodeIndex.Tests/CommandErrorWriterTests.cs - tests/CodeIndex.Tests/TestConsoleLock.cs - tests/CodeIndex.Tests/ConsoleCaptureTests.cs + - tests/CodeIndex.Tests/DiffCommandHelpersTests.cs + - tests/CodeIndex.Tests/LicensePolicyTests.cs + - tests/CodeIndex.Tests/ProgramCliTests.cs + - tests/CodeIndex.Tests/SymbolExtractorTests.cs + - tests/CodeIndex.Tests/TestTelemetryTests.cs - TESTING_GUIDE.md --- ## English -- **Console-sensitive tests no longer capture concurrent request-id logs (#4798)** — the shared console-sensitive xUnit collection is now non-parallel, preventing MCP request-id and global diagnostic lines from unrelated tests from entering captured stdout or stderr. +- **Console-sensitive tests no longer capture concurrent request-id logs (#4798)** — every test class that owns process-global console streams now belongs to a non-parallel collection, preventing MCP request-id and global diagnostic lines from unrelated tests from entering captured stdout or stderr. ## 日本語 -- **console-sensitive test が並行実行された request-id log を取り込まないようになりました (#4798)** — 共有の console-sensitive xUnit collection を non-parallel にし、無関係なテストの MCP request-id や global diagnostic 行が capture 中の stdout / stderr に混入することを防ぎます。 +- **console-sensitive test が並行実行された request-id log を取り込まないようになりました (#4798)** — process-global な console stream を占有する全テストクラスを non-parallel collection に所属させ、無関係なテストの MCP request-id や global diagnostic 行が capture 中の stdout / stderr に混入することを防ぎます。 diff --git a/tests/CodeIndex.Tests/AuditLogSinkTests.cs b/tests/CodeIndex.Tests/AuditLogSinkTests.cs index ce6cfbd65..458b8c016 100644 --- a/tests/CodeIndex.Tests/AuditLogSinkTests.cs +++ b/tests/CodeIndex.Tests/AuditLogSinkTests.cs @@ -8,6 +8,7 @@ namespace CodeIndex.Tests; +[Collection("Console sensitive")] public class AuditLogSinkTests { [Fact] diff --git a/tests/CodeIndex.Tests/CliFlagSchemaTests.cs b/tests/CodeIndex.Tests/CliFlagSchemaTests.cs index 5b92c111d..e48a184e0 100644 --- a/tests/CodeIndex.Tests/CliFlagSchemaTests.cs +++ b/tests/CodeIndex.Tests/CliFlagSchemaTests.cs @@ -14,6 +14,7 @@ namespace CodeIndex.Tests; /// #1570 で導入した「フラグ単一情報源」の契約を守るためのテスト群。スキーマと /// 補完スクリプト、コマンド一覧、parser-vs-completion の許容差分がずれた瞬間に失敗する。 /// +[Collection("Console sensitive")] public class CliFlagSchemaTests { [Fact] diff --git a/tests/CodeIndex.Tests/CommandErrorWriterTests.cs b/tests/CodeIndex.Tests/CommandErrorWriterTests.cs index 49c915f15..756930a91 100644 --- a/tests/CodeIndex.Tests/CommandErrorWriterTests.cs +++ b/tests/CodeIndex.Tests/CommandErrorWriterTests.cs @@ -2,6 +2,7 @@ namespace CodeIndex.Tests; +[Collection("Console sensitive")] public class CommandErrorWriterTests { [Fact] diff --git a/tests/CodeIndex.Tests/ConsoleCaptureTests.cs b/tests/CodeIndex.Tests/ConsoleCaptureTests.cs index 3ea65edff..b5fa0d044 100644 --- a/tests/CodeIndex.Tests/ConsoleCaptureTests.cs +++ b/tests/CodeIndex.Tests/ConsoleCaptureTests.cs @@ -6,12 +6,30 @@ namespace CodeIndex.Tests; public class ConsoleCaptureTests { [Fact] - public void ConsoleSensitiveCollection_AssignsImportCancellationAndDisablesParallelization_Issues4650_4798() + public void ConsoleSensitiveCollection_AssignsGlobalCaptureClassesAndDisablesParallelization_Issues4650_4798() { - var attribute = Assert.Single( - typeof(ExportImportCommandRunnerCancellationTests).CustomAttributes, - static candidate => candidate.AttributeType == typeof(CollectionAttribute)); - var collectionName = Assert.Single(attribute.ConstructorArguments); + Type[] consoleSensitiveTypes = + [ + typeof(AuditLogSinkTests), + typeof(CliFlagSchemaTests), + typeof(CommandErrorWriterTests), + typeof(DiffCommandHelpersTests), + typeof(ExportImportCommandRunnerCancellationTests), + typeof(LicensePolicyTests), + typeof(ProgramCliTests), + typeof(SymbolExtractorTests), + typeof(TestTelemetryTests), + ]; + + foreach (var type in consoleSensitiveTypes) + { + var attribute = Assert.Single( + type.CustomAttributes, + static candidate => candidate.AttributeType == typeof(CollectionAttribute)); + var collectionName = Assert.Single(attribute.ConstructorArguments); + Assert.Equal("Console sensitive", collectionName.Value); + } + var definition = Assert.Single( typeof(ConsoleSensitiveCollection).CustomAttributes, static candidate => candidate.AttributeType == typeof(CollectionDefinitionAttribute)); @@ -19,7 +37,6 @@ public void ConsoleSensitiveCollection_AssignsImportCancellationAndDisablesParal definition.NamedArguments, static candidate => candidate.MemberName == nameof(CollectionDefinitionAttribute.DisableParallelization)); - Assert.Equal("Console sensitive", collectionName.Value); Assert.True(Assert.IsType(disableParallelization.TypedValue.Value)); } diff --git a/tests/CodeIndex.Tests/DiffCommandHelpersTests.cs b/tests/CodeIndex.Tests/DiffCommandHelpersTests.cs index 0b076081b..6c435a0c2 100644 --- a/tests/CodeIndex.Tests/DiffCommandHelpersTests.cs +++ b/tests/CodeIndex.Tests/DiffCommandHelpersTests.cs @@ -3,6 +3,7 @@ namespace CodeIndex.Tests; +[Collection("Console sensitive")] public sealed class DiffCommandHelpersTests { [Fact] diff --git a/tests/CodeIndex.Tests/LicensePolicyTests.cs b/tests/CodeIndex.Tests/LicensePolicyTests.cs index 177b7500d..65e7f32b2 100644 --- a/tests/CodeIndex.Tests/LicensePolicyTests.cs +++ b/tests/CodeIndex.Tests/LicensePolicyTests.cs @@ -6,6 +6,7 @@ namespace CodeIndex.Tests; /// Guards licensing and distribution metadata from silently drifting back to /// permissive productization defaults. /// +[Collection("Console sensitive")] public class LicensePolicyTests { private static readonly string[] CanonicalLegalNoticeFiles = diff --git a/tests/CodeIndex.Tests/ProgramCliTests.cs b/tests/CodeIndex.Tests/ProgramCliTests.cs index 72f0b3b4b..ac44d7b6e 100644 --- a/tests/CodeIndex.Tests/ProgramCliTests.cs +++ b/tests/CodeIndex.Tests/ProgramCliTests.cs @@ -16,6 +16,7 @@ namespace CodeIndex.Tests; /// Black-box CLI tests for Program entrypoint behavior. /// Program エントリポイント挙動のブラックボックステスト。 /// +[Collection("Console sensitive")] public class ProgramCliTests { [ProductionRuntimeFact] diff --git a/tests/CodeIndex.Tests/SymbolExtractorTests.cs b/tests/CodeIndex.Tests/SymbolExtractorTests.cs index 3777c609b..59350eada 100644 --- a/tests/CodeIndex.Tests/SymbolExtractorTests.cs +++ b/tests/CodeIndex.Tests/SymbolExtractorTests.cs @@ -16,6 +16,7 @@ namespace CodeIndex.Tests; /// Tests for SymbolExtractor. /// SymbolExtractorのテスト。 /// +[Collection("Console sensitive")] public partial class SymbolExtractorTests { private static void AssertSymbolsContain( diff --git a/tests/CodeIndex.Tests/TestTelemetryTests.cs b/tests/CodeIndex.Tests/TestTelemetryTests.cs index 1d8cd0bd9..c13aa67e7 100644 --- a/tests/CodeIndex.Tests/TestTelemetryTests.cs +++ b/tests/CodeIndex.Tests/TestTelemetryTests.cs @@ -4,6 +4,7 @@ namespace CodeIndex.Tests; +[Collection("Console sensitive")] public sealed class TestTelemetryTests { [Fact]