test(#3103): expect git's separators, not the ones this machine happens to use
The Windows shard failed on the worktree-root assertion: actual C:/Users/runneradmin/AppData/Local/Temp/gsd-wt-info-Nn4hj6 expected C:\Users\runneradmin\AppData\Local\Temp\gsd-wt-info-Nn4hj6 The value comes straight from `git rev-parse --show-toplevel`, and git reports POSIX separators on every platform. The expected side was built with the native realpath, so the test encoded the separator convention of the machine it was written on. Normalising the expected side keeps the assertion exact — on POSIX the replacement is a no-op, so nothing is weakened where it already passed. This is the same assertion that was strengthened earlier today from a typeof-string-and-non-empty shape check. Pinning the exact path was right; the weaker version would have passed on Windows precisely because it asserted almost nothing. Getting a real assertion wrong on one platform is the better failure, and the Linux-only matrix could not see it — the platform shards caught it, as they did twice in the previous wave. Every other path comparison in the two new test files was swept for the same mistake. The remaining ones are safe: the base-branch tests compare against literal POSIX strings supplied to a mocked git, and the reap tests put both sides through one canonicalising helper, so they cannot disagree on separators. Drive-letter case can differ in principle at the fixed site; it did not here and no case-folding was added on speculation. Refs #3057 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -288,8 +288,18 @@ describe('#1268 gitWorktreeInfoInternal: relocation to git-base-branch', () => {
|
||||
// exact value rather than "a non-empty string": a resolver that returned the
|
||||
// .git dir, the cwd, or any other plausible-looking path would pass the weaker
|
||||
// shape check while being wrong.
|
||||
//
|
||||
// git always reports POSIX forward slashes, on every platform including
|
||||
// Windows, while `fs.realpathSync.native` returns the platform's native
|
||||
// form (backslashes on Windows). The expected side must therefore be
|
||||
// normalized to git's convention rather than compared to the raw native
|
||||
// realpath, or the assertion just encodes the separator convention of
|
||||
// whatever platform it was written on. This is separators only — POSIX's
|
||||
// `replace` is a no-op there, so the assertion keeps its full strength on
|
||||
// POSIX. The remote gsd-test matrix is Linux-only and cannot exercise this
|
||||
// path; it only surfaced on the Windows GitHub Actions shard.
|
||||
assert.strictEqual(result.inside, true, 'inside must be true for a git project dir');
|
||||
assert.strictEqual(result.worktreeRoot, fs.realpathSync.native(dir),
|
||||
assert.strictEqual(result.worktreeRoot, fs.realpathSync.native(dir).replace(/\\/g, '/'),
|
||||
'worktreeRoot must be the resolved worktree root path');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user