Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Use the full suite by default. Use targeted filters only while iterating locally

## Test Stack

- Issue #5130 keeps the commit-diff timeout regression focused on `diff-tree`: its fake git must echo the commit being verified by `rev-parse --verify <ref>^{commit}`, then the test must confirm the timed-out child process is reaped. Keep production single-commit validation strict.
- Issue #5128 compact graph zero-result coverage belongs in `JsonEnvelopeWrapperIssue4585Tests.cs`. Keep `callees` aligned with `references` and `callers` by asserting an empty compact location envelope and zero returned/total cardinality both with and without explicit `--fields`, while reusing the graph-ready bounded-response fixture.
- Issue #5098 inspect projection coverage belongs in `QueryCommandRunnerInspectTests.cs`. Keep one graph-ready partial-type fixture covering canonical and alias selectors, multiple leaves across collections, parent-over-child precedence, stable row order, empty arrays, compact truncation, byte bounds, body paging/recovery, partial-family metadata, queryless catalog discovery, and typed unknown parent/leaf errors. `ConsoleUiTests.cs` separately pins the `<csv|list>` usage, nested-field help text, and examples.
- Path-containment coverage for #5091 pairs platform-independent `PathCasingTests` seams for mixed parent-namespace case policies and directory identities with `FileIndexerTests` integration through an internal file symlink. Keep both checks when changing internal-symlink policy: a case-insensitive project mount must not make a distinct case-only sibling in its case-sensitive parent namespace appear internal, while genuine same-namespace aliases remain accepted.
Expand Down Expand Up @@ -1114,6 +1115,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"

## テストスタック

- Issue #5130 の commit-diff timeout regression は `diff-tree` に焦点を維持します。fake git は `rev-parse --verify <ref>^{commit}` で検証対象の commit を返し、テストでは timeout した子プロセスが reap されることを確認してください。本番の single-commit validation は厳格なままにします。
- Issue #5128 の compact graph 0件 coverage は `JsonEnvelopeWrapperIssue4585Tests.cs` が担当します。graph-ready な bounded-response fixture を再利用し、明示的な `--fields` の有無の両方で、`callees` が `references` / `callers` と同様に空の compact location envelope と返却件数・総件数0を維持することを検証してください。
- Issue #5098 の inspect projection coverage は `QueryCommandRunnerInspectTests.cs` が担当します。graph-ready な partial type fixture 1つで canonical / alias selector、collection をまたぐ複数 leaf、parent の child に対する優先、安定した row 順、空配列、compact truncation、byte 上限、body paging / recovery、partial-family metadata、query 不要の catalog discovery、未知 parent / leaf の型付き error を維持してください。`ConsoleUiTests.cs` では `<csv|list>` usage、nested-field help text、例を別途固定します。
- #5091 の path containment coverage は、親 directory namespace の case policy と directory identity が混在する状況を OS 非依存で再現する `PathCasingTests` の seam と、内部 file symlink を通す `FileIndexerTests` の integration を対にします。internal-symlink policy を変更するときは両方を維持し、case-insensitive な project mount の policy で、case-sensitive な親 namespace にある別 identity の case-only sibling を内部 path と誤認しないこと、および同一 namespace の正当な alias は引き続き受理されることを検証してください。
Expand Down
16 changes: 16 additions & 0 deletions changelog.d/unreleased/5130.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
category: fixed
issues:
- 5130
affected:
- tests/CodeIndex.Tests/GitHelperTests.cs
- TESTING_GUIDE.md
---

## English

- **The commit-diff timeout regression now reaches `diff-tree` (#5130)** — the fake git validation response follows the temporary commit under test, preserving strict single-commit validation while allowing the timeout path to verify child-process cleanup.

## 日本語

- **commit-diff timeout regression が `diff-tree` に到達するようになりました (#5130)** — fake git の validation 応答をテスト対象の一時 commit と一致させ、厳格な single-commit validation を維持しながら timeout 経路で子プロセスの cleanup を検証できるようにしました。
19 changes: 11 additions & 8 deletions tests/CodeIndex.Tests/GitHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public void GetChangedFilesFromCommit_FailsWhenGitCommandTimesOut()

var fakeGitDir = Path.Combine(_tempDir, "fake-git-timeout");
Directory.CreateDirectory(fakeGitDir);
WriteFakeGitThatHangsOnDiffTree(fakeGitDir);
WriteFakeGitThatHangsOnDiffTree(fakeGitDir, commitId);
var fakeGitPidPath = Path.Combine(fakeGitDir, "diff-tree.pid");

var oldGitExecutablePath = GitHelper.GitExecutablePathOverride;
Expand Down Expand Up @@ -971,7 +971,8 @@ public void GetChangedFilesFromCommit_CancelDuringGitCommand_ThrowsOperationCanc
Directory.CreateDirectory(repoDir);
var fakeGitDir = Path.Combine(_tempDir, "fake-git-cancel");
Directory.CreateDirectory(fakeGitDir);
WriteFakeGitThatHangsOnDiffTree(fakeGitDir);
const string commitId = "0123456789abcdef";
WriteFakeGitThatHangsOnDiffTree(fakeGitDir, commitId);

var oldGitExecutablePath = GitHelper.GitExecutablePathOverride;
GitHelper.GitExecutablePathOverride = Path.Combine(fakeGitDir, "git");
Expand All @@ -982,7 +983,7 @@ public void GetChangedFilesFromCommit_CancelDuringGitCommand_ThrowsOperationCanc
var stopwatch = Stopwatch.StartNew();

var ex = Assert.Throws<OperationCanceledException>(
() => GitHelper.GetChangedFilesFromCommit(repoDir, "0123456789abcdef", cts.Token));
() => GitHelper.GetChangedFilesFromCommit(repoDir, commitId, cts.Token));

stopwatch.Stop();
Assert.Equal(cts.Token, ex.CancellationToken);
Expand Down Expand Up @@ -1835,27 +1836,29 @@ exit 0
File.SetUnixFileMode(script, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
}

private static void WriteFakeGitThatHangsOnDiffTree(string directory)
private static void WriteFakeGitThatHangsOnDiffTree(string directory, string verifiedCommit)
{
var script = Path.Combine(directory, "git");
File.WriteAllText(script, $$"""
File.WriteAllText(script, """
#!/bin/sh
if [ "$1" = "rev-parse" ]; then
if [ "$2" = "--symbolic-full-name" ]; then
exit 0
fi
if [ "$2" = "--verify" ]; then
printf '%s\n' '0123456789abcdef0123456789abcdef01234567'
printf '%s\n' '__VERIFIED_COMMIT__'
exit 0
fi
fi
if [ "$1" = "diff-tree" ]; then
printf '%s\n' "$$" > "$(dirname "$0")/diff-tree.pid"
sleep {{FakeGitHangSeconds}}
sleep __HANG_SECONDS__
exit 0
fi
exit 1
""");
"""
.Replace("__VERIFIED_COMMIT__", verifiedCommit, StringComparison.Ordinal)
.Replace("__HANG_SECONDS__", FakeGitHangSeconds.ToString(System.Globalization.CultureInfo.InvariantCulture), StringComparison.Ordinal));
if (!OperatingSystem.IsWindows())
File.SetUnixFileMode(script, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
}
Expand Down
Loading