fix(windows): harden nested-root and archive-warning assertions
This commit is contained in:
@@ -98,7 +98,22 @@ function getInitGitState(cwd) {
|
||||
return resolved;
|
||||
};
|
||||
|
||||
let inNestedSubdir = info.inside && worktreeRoot !== null;
|
||||
// Most reliable signal: git reports a non-empty prefix only when cwd is
|
||||
// below the worktree root. This avoids short/long path alias issues on Windows.
|
||||
let inNestedSubdir = false;
|
||||
if (info.inside) {
|
||||
try {
|
||||
const prefixResult = execGit(['rev-parse', '--show-prefix'], { cwd, timeout: 5000 });
|
||||
if (prefixResult.exitCode === 0) {
|
||||
inNestedSubdir = String(prefixResult.stdout || '').trim().length > 0;
|
||||
} else {
|
||||
inNestedSubdir = worktreeRoot !== null;
|
||||
}
|
||||
} catch {
|
||||
inNestedSubdir = worktreeRoot !== null;
|
||||
}
|
||||
}
|
||||
|
||||
if (inNestedSubdir) {
|
||||
const rootNorm = normalizeForCompare(worktreeRoot);
|
||||
const cwdNorm = normalizeForCompare(cwd);
|
||||
|
||||
@@ -100,7 +100,18 @@ describe('#1974 context exhaustion auto-record', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
const sleep = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
||||
for (let attempt = 0; attempt < 5; attempt += 1) {
|
||||
try {
|
||||
cleanup(tmpDir);
|
||||
break;
|
||||
} catch (err) {
|
||||
const code = err && err.code;
|
||||
const transient = code === 'EPERM' || code === 'EBUSY' || code === 'ENOTEMPTY';
|
||||
if (!transient || attempt === 4) throw err;
|
||||
sleep(250 * (attempt + 1));
|
||||
}
|
||||
}
|
||||
// Clean up bridge files
|
||||
try {
|
||||
const warnPath = path.join(os.tmpdir(), `claude-ctx-${sessionId}-warned.json`);
|
||||
|
||||
@@ -159,12 +159,12 @@ describe('#3164 — validate consistency: milestone-archive layout', () => {
|
||||
`Old archived milestone phase 64 should not be treated as active:\n ${phase64Warnings.join('\n ')}`
|
||||
);
|
||||
assert.ok(
|
||||
warningsPosix.some(w => w.includes('Gap in plan numbering in milestones/v1.7-phases/65-current')),
|
||||
warningsPosix.some(w => /Gap in plan numbering in .*milestones\/v1\.7-phases\/65-current/.test(w)),
|
||||
`Expected plan numbering warning from active archive root, got:\n ${warnings.join('\n ')}`
|
||||
);
|
||||
assert.ok(
|
||||
warningsPosix.some(w => w.includes("milestones/v1.7-phases/65-current/65-01-PLAN.md: missing 'wave'"))
|
||||
|| warningsPosix.some(w => w.includes("milestones/v1.7-phases/65-current/65-03-PLAN.md: missing 'wave'")),
|
||||
warningsPosix.some(w => /milestones\/v1\.7-phases\/65-current\/65-01-PLAN\.md: missing 'wave'/.test(w))
|
||||
|| warningsPosix.some(w => /milestones\/v1\.7-phases\/65-current\/65-03-PLAN\.md: missing 'wave'/.test(w)),
|
||||
`Expected frontmatter warning from active archive plans, got:\n ${warnings.join('\n ')}`
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user