From 9ba3c8e9a3012eaa5824135438dcbf1b299cfe50 Mon Sep 17 00:00:00 2001 From: Widthdom Date: Mon, 15 Jun 2026 08:15:12 +0900 Subject: [PATCH] Fix GitHelper cancellation test threshold (#3643) --- TESTING_GUIDE.md | 4 ++-- changelog.d/unreleased/3643.fixed.md | 16 ++++++++++++++++ tests/CodeIndex.Tests/GitHelperTests.cs | 11 +++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 changelog.d/unreleased/3643.fixed.md diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index 8f42579533..87df86d3a9 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -61,7 +61,7 @@ The test project mirrors the production areas closely. - `HttpMcpTransportTests.cs` HTTP MCP transport behavior, including authentication responses, warm server reuse, concurrent requests, and request logging. Request-log assertions must validate recorded contents without assuming callback order between independently handled HTTP requests. - `GitHelperTests.cs` - Git-specific behavior, including worktrees and commit-based updates. + Git-specific behavior, including worktrees, commit-based updates, and cancellation of git subprocesses. Cancellation wall-clock assertions should stay below the fake git scripts' natural 5-second completion while leaving room for macOS CI scheduling and process-cleanup overhead. - `WorkspaceMetadataEnricherTests.cs` Workspace freshness and git metadata enrichment behavior. - `SuggestionStoreTests.cs` @@ -269,7 +269,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests" - `HttpMcpTransportTests.cs` HTTP MCP transport の挙動。認証レスポンス、warm server reuse、並行リクエスト、リクエストログを含みます。リクエストログの assertion は、独立に処理される HTTP リクエスト間の callback 順序を仮定せず、記録内容を検証してください。 - `GitHelperTests.cs` - worktree や commit ベース更新を含む Git まわりのテスト。 + worktree や commit ベース更新、git subprocess の cancellation を含む Git まわりのテスト。Cancellation の wall-clock assertion は fake git script が自然完了する 5 秒未満に保ちつつ、macOS CI の scheduling や process cleanup の遅れを許容する余裕を持たせます。 - `WorkspaceMetadataEnricherTests.cs` ワークスペース鮮度と git メタデータ付与のテスト。 - `SuggestionStoreTests.cs` diff --git a/changelog.d/unreleased/3643.fixed.md b/changelog.d/unreleased/3643.fixed.md new file mode 100644 index 0000000000..ef70b15a56 --- /dev/null +++ b/changelog.d/unreleased/3643.fixed.md @@ -0,0 +1,16 @@ +--- +category: fixed +issues: + - 3643 +affected: + - tests/CodeIndex.Tests/GitHelperTests.cs + - TESTING_GUIDE.md +--- + +## English + +- **GitHelper cancellation tests now tolerate macOS CI cleanup jitter (#3643)** — cancellation assertions keep a bounded wall-clock limit while allowing small scheduling and process-cleanup overhead above the previous two-second cutoff. + +## 日本語 + +- **GitHelper の cancellation テストが macOS CI の cleanup 揺れを許容するようになりました (#3643)** — cancellation の assertion は wall-clock の上限を維持しつつ、従来の 2 秒閾値を少し超える scheduling や process cleanup の遅れを許容します。 diff --git a/tests/CodeIndex.Tests/GitHelperTests.cs b/tests/CodeIndex.Tests/GitHelperTests.cs index f162100357..d4915e18f4 100644 --- a/tests/CodeIndex.Tests/GitHelperTests.cs +++ b/tests/CodeIndex.Tests/GitHelperTests.cs @@ -11,6 +11,9 @@ namespace CodeIndex.Tests; [Collection("SQLite pool sensitive")] public class GitHelperTests : IDisposable { + // Keep below the fake git scripts' 5-second sleep so missed cancellation still fails. + private static readonly TimeSpan GitCancellationWallClockLimit = TimeSpan.FromSeconds(4); + private readonly string _tempDir; public GitHelperTests() @@ -622,7 +625,9 @@ public void GetChangedFilesFromCommit_CancelDuringGitCommand_ThrowsOperationCanc stopwatch.Stop(); Assert.Equal(cts.Token, ex.CancellationToken); - Assert.True(stopwatch.Elapsed < TimeSpan.FromSeconds(2), $"Cancellation took {stopwatch.Elapsed}."); + Assert.True( + stopwatch.Elapsed < GitCancellationWallClockLimit, + $"Cancellation took {stopwatch.Elapsed}, expected less than {GitCancellationWallClockLimit}."); } finally { @@ -655,7 +660,9 @@ public void ResolveIgnoreCase_CancelDuringGitCommand_ThrowsOperationCanceled() stopwatch.Stop(); Assert.Equal(cts.Token, ex.CancellationToken); - Assert.True(stopwatch.Elapsed < TimeSpan.FromSeconds(2), $"Cancellation took {stopwatch.Elapsed}."); + Assert.True( + stopwatch.Elapsed < GitCancellationWallClockLimit, + $"Cancellation took {stopwatch.Elapsed}, expected less than {GitCancellationWallClockLimit}."); } finally {