Skip to content

Use extended-length paths for Tsavorite test MethodTestDir - #2045

Merged
Ted Hart (TedHartMS) merged 3 commits into
mainfrom
tedhar/tsav-test-path
Aug 10, 2026
Merged

Ted Hart (TedHartMS) merged 3 commits into
mainfrom
tedhar/tsav-test-path

Conversation

@TedHartMS

Copy link
Copy Markdown
Contributor

What

Route the Tsavorite test helper TestUtils.MethodTestDir through a new EnsureExtendedLengthPathIfNeeded helper that rewrites the test directory as a Win32 extended-length path (\\?\..., or \\?\UNC\... for network shares) when its fully-qualified length gets within 100 chars of the 260-char MAX_PATH limit. Short paths (normal checkouts and CI) are returned unchanged.

Why

Recovery tests in Tsavorite.test (e.g. Tsavorite.test.recovery) fail with Path ... is too long when the repo is checked out under a deep directory path. The test base dir itself fits under MAX_PATH, but derived checkpoint/device files (e.g. ...\<iter>\checkpoints\cpr-checkpoints\<guid>\snapshot.obj.dat) push the full path past 260 chars, and the device layer rejects non-extended paths longer than WIN32_MAX_PATH - 11.

Note: This surfaced because the GitHub Copilot App creates worktrees under longer, generated directory names (e.g. ...\copilot-worktrees\garnet\<worktree-name>\...), which pushed the derived test paths past MAX_PATH. The fix makes the test infra robust to deep checkout/worktree locations regardless of how they're created.

Extended-length paths are exempt from MAX_PATH and are already honored by the device layer (passed straight to CreateFileW) and the BCL file APIs, so no production code changes are needed — this is a test-infrastructure-only fix.

How

  • MethodTestDir now wraps its result in EnsureExtendedLengthPathIfNeeded(...).
  • The helper fully-qualifies the path first (via Path.GetFullPath, so forward slashes / relative segments are normalized to backslashes as extended-length paths require), then prefixes \\?\ (or \\?\UNC\) only when needed. It's a no-op on non-Windows, on already-extended paths, and on short paths.
  • Added regression test LogPathExtendedLengthSupport (Windows-guarded) verifying short paths are untouched, over-MAX_PATH paths get the \\?\ prefix idempotently, and a device can be created at an extended path beyond 260 chars.

Testing

Check Result
Tsavorite.test.recovery (before) 21 failed — all Path ... is too long
Tsavorite.test.recovery (after) 0 path failures
Full Tsavorite.test suite 285 passed / 0 failed
dotnet format / build clean / 0 warnings

Recovery tests in Tsavorite.test fail with "Path ... is too long" when run
from deep directory paths, because derived checkpoint/device file paths
exceed the 260-char Win32 MAX_PATH limit.

Route MethodTestDir through a new EnsureExtendedLengthPathIfNeeded helper,
which rewrites the directory as a Win32 extended-length path (\\?\..., or
\\?\UNC\... for shares) when its fully-qualified length is within 100 chars
of MAX_PATH. Short paths (normal checkouts and CI) are returned unchanged.
The device layer and BCL file APIs already honor \\?\ paths, so no
production code changes are needed.

Add regression test LogPathExtendedLengthSupport.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a0a4e097-0130-46dd-89a9-84d071a69307

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Tsavorite test infrastructure on Windows by automatically switching the per-test output directory (TestUtils.MethodTestDir) to a Win32 extended-length path (\\?\... / \\?\UNC\...) when the fully-qualified path is close to the 260-character MAX_PATH limit, preventing recovery and checkpoint tests from failing under deep checkout/worktree locations.

Changes:

  • Route TestUtils.MethodTestDir through a new EnsureExtendedLengthPathIfNeeded(...) helper that conditionally applies the extended-length prefix on Windows.
  • Add a Windows-only regression test (LogPathExtendedLengthSupport) validating idempotent conversion and successful log device creation beyond MAX_PATH.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
libs/storage/Tsavorite/cs/test/TestUtils.cs Adds extended-length path helper and applies it to MethodTestDir to avoid long-path failures in tests.
libs/storage/Tsavorite/cs/test/BasicTests.cs Adds a Windows-guarded regression test covering extended-length path behavior and device creation beyond MAX_PATH.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/storage/Tsavorite/cs/test/TestUtils.cs Outdated
Address PR review feedback: the remarks implied Path.GetFullPath
normalization always runs, but the short-path branch returns the original
input unchanged. Reword to make clear canonicalization only happens on the
extended-length rewrite path.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a0a4e097-0130-46dd-89a9-84d071a69307
@TedHartMS
Ted Hart (TedHartMS) merged commit a80e26b into main Aug 10, 2026
432 of 433 checks passed
@TedHartMS
Ted Hart (TedHartMS) deleted the tedhar/tsav-test-path branch August 10, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants