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 @@ -178,6 +178,7 @@ Use `docs/test-doc-maintenance-plan.md` before moving oversized suites or adding
CLI parsing, command execution, and installer behavior. Index command coverage is split by run mode or feature area, and query command coverage is split by command family with partial test classes so shared console and fixture helpers stay centralized. Keep repeated query-result fixtures, such as overlapping chunk content used by multiple search deduplication tests, in narrow class-level helpers instead of duplicating local builders. `ProgramCliTests.cs` covers top-level entrypoint behavior that must be exercised through a subprocess, while `InstallScriptTests.cs` runs focused bash snippets against `install.sh` in library mode to lock in release-installer regressions without performing real network installs. Installer bundle-generation tests must also verify that `install.sh` is marked generated while every canonical `install_modules/` source remains unmarked.
`ConsoleUiTests.cs` keeps each generated shell's complete long-flag catalog aligned with `CliFlagSchema` and checks every Fish command scope against the shared per-command completion projection. Add flags to the schema rather than weakening this Bash / Zsh / Fish / PowerShell parity contract.
`ProgramRunnerTests.cs` enumerates `CliCommandCatalog.CommandSubcommands` and requires every valid nested verb to resolve to verb-specific usage with an example. It also pins destructive index confirmation and aggregate dependency-filter help, plus the read-only GitHub duplicate-preflight boundary for suggestion exports. Installer cancellation coverage must wait until the PID file contains a complete positive integer before cancelling, using a bounded dedicated waiter instead of a fixed-delay timer so parallel load cannot expose a redirection-created empty file.
Global-tool-log home-shorthand coverage resolves the normalized first candidate through the test-only no-write-probe seam, so sandbox permissions cannot turn an expansion assertion into a writability-fallback assertion.
Grouped-search limit coverage must seed more matches and files than the returned page, then assert query-wide matched/group/file totals separately from grouped, emitted, and omitted row counts so a bounded page cannot report itself as complete.
Cursor-pagination coverage for `outline` and `unused` must replay the emitted opaque token successfully, then prove that changed filters/order and a changed index-generation stamp fail with restart-required diagnostics.
Discovery-pagination coverage must page compact search/symbol/file output and the opt-in search-array/languages envelopes, assert authoritative total/omitted/stable-at metadata, reject query or generation cursor mismatches, and prove that a partial `find --all` scan resumes after the last scanned line.
Expand Down Expand Up @@ -1032,6 +1033,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
CLI の引数解析、コマンド実行、installer 挙動のテスト。Index command coverage は run mode または機能領域ごとの partial suite に分割し、Query command coverage は command family ごとの partial test class に分割して、共有 console / fixture helper は一箇所に保ちます。`ProgramCliTests.cs` はグローバル引数の解釈や完全な CLI 起動フローのように subprocess 経由で確認すべき Program エントリポイント挙動を扱い、`InstallScriptTests.cs` は `install.sh` を library mode で source した bash snippet を実行して、実ネットワーク install を行わずに release installer の回帰を固定する。installer bundle 生成テストでは、`install.sh` が generated と判定される一方、canonical な `install_modules/` source はすべて unmarked のままであることも検証してください。
`ConsoleUiTests.cs` は各生成シェルの long flag 全カタログを `CliFlagSchema` と同期させ、Fish の全 command scope を共有の command 別 completion 射影と照合します。この Bash / Zsh / Fish / PowerShell parity 契約を弱めず、新しい flag は schema に追加してください。
`ProgramRunnerTests.cs` は `CliCommandCatalog.CommandSubcommands` を列挙し、すべての有効な nested verb が例を含む verb 固有 usage に解決されることを必須とします。さらに destructive な index confirmation、aggregate dependency filter help、suggestion export の read-only GitHub duplicate-preflight 境界を固定します。installer cancellation coverage は固定時間タイマーではなく上限付きの専用 waiter を使い、PID ファイルが完全な正の整数を含むまで待ってから cancel してください。これにより並列負荷下でも redirection によって作成された空ファイルを読みません。
global tool log の home shorthand coverage は、test 専用の write probe なし seam から正規化済みの先頭 candidate を解決します。これにより sandbox permission の影響で、展開の assertion が writability fallback の assertion に変わることを防ぎます。
grouped search の limit coverage では、返却 page より多い match と file を seed し、query 全体の match/group/file 総数と grouped、emitted、omitted row 数を別々に検証して、上限付き page が完了済みと報告できないようにしてください。
`outline` と `unused` の cursor pagination coverage では、出力された opaque token の再利用成功に加え、filter/order の変更と index-generation stamp の変更が restart-required 診断で失敗することを検証してください。
discovery pagination の coverage では compact search / symbol / file と opt-in の search array / languages envelope をページングし、authoritative な total / omitted / stable-at metadata、query / generation 不一致 cursor の拒否、partial な `find --all` scan が最後に scan した line の次から再開することを検証してください。
Expand Down
17 changes: 17 additions & 0 deletions changelog.d/unreleased/4810.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
category: fixed
issues:
- 4810
affected:
- src/CodeIndex/Cli/GlobalToolLog.cs
- tests/CodeIndex.Tests/ProgramRunnerTests.cs
- TESTING_GUIDE.md
---

## English

- **Isolated global-tool-log home-shorthand tests from sandbox writability fallback (#4810)** — the test now verifies the resolver's normalized first candidate through a no-write-probe test seam, while production resolution continues to require a writable directory.

## 日本語

- **global tool log の home shorthand テストを sandbox の writability fallback から分離しました (#4810)** — test は write probe なし seam から resolver の正規化済み先頭 candidate を検証し、production の解決では引き続き書込可能な directory を必須とします。
9 changes: 7 additions & 2 deletions src/CodeIndex/Cli/GlobalToolLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,19 @@ private static bool ContainsPathSegments(string path, string[] expectedSegments,

internal static string ResolveLogDirectoryForStatus() => ResolveLogDirectory();

private static string ResolveLogDirectory()
private static string ResolveLogDirectory() => ResolveLogDirectory(requireWritableCandidate: true);

internal static string ResolveLogDirectoryWithoutWriteProbeForTesting()
=> ResolveLogDirectory(requireWritableCandidate: false);

private static string ResolveLogDirectory(bool requireWritableCandidate)
{
foreach (var candidate in EnumerateLogDirectoryCandidates())
{
if (!TryNormalizeLogDirectoryCandidate(candidate, out var fullPath))
continue;

if (CanWriteProbe(fullPath))
if (!requireWritableCandidate || CanWriteProbe(fullPath))
return fullPath;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CodeIndex.Tests/ProgramRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4169,7 +4169,7 @@ public void GlobalToolLog_OverrideDirectory_ExpandsHomeShorthand(string override
env.Set("XDG_RUNTIME_DIR", null);
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

var resolved = GlobalToolLog.ResolveLogDirectoryForReport();
var resolved = GlobalToolLog.ResolveLogDirectoryWithoutWriteProbeForTesting();

Assert.Equal(Path.GetFullPath(Path.Combine(home, childDirectory)), resolved);
}
Expand Down
Loading