fix(windows): owned-read requires the read-only attribute on Windows; setup.ps1 passes arguments NUL-separated through a private file; Windows-only tests expect the owned-read approval

This commit is contained in:
garrytan committed 2026-10-08 16:51:43 +00:00
1 parent cb919cc770
commit d2b601d9ae
5 files changed
+21 -9

No files matched your search

+1 -1
View File
@@ -124,7 +124,7 @@ describe('/autoplan owned reads after the skill turn', () => {
const first = run(), second = run();
expect(first.status).toBe(0); expect(second.status).toBe(0);
const restore = /^RESTORE_PATH=(.+)$/m.exec(first.stdout)?.[1] ?? '';
expect(path.dirname(restore)).toBe(path.join(repo, '.gstack', 'tmp', 'autoplan'));
expect(path.resolve(path.dirname(restore))).toBe(path.join(repo, '.gstack', 'tmp', 'autoplan'));
expect(path.basename(restore)).toMatch(/-autoplan-restore-\d{8}-\d{6}\.md$/);
expect(fs.readFileSync(path.join(repo, '.git', 'info', 'exclude'), 'utf8').split('\n').filter(l => l === '/.gstack/tmp/')).toHaveLength(1);
expect(spawnSync('git', ['status', '--porcelain', '--untracked-files=all'], { cwd: repo, encoding: 'utf8', timeout: 10_000 }).stdout).toBe('');
+3 -3
View File
@@ -1274,8 +1274,8 @@ describe('Autoplan native journal roots and Windows spellings', () => {
test.if(windows)('CLAUDE_PROJECT_DIR spelled C:/ or c:\\ names the native journal cwd', async () => {
const { f } = published();
expect(await hook(f, f.cwd.replaceAll('\\', '/'))).toEqual({});
expect(await hook(f, f.cwd[0]!.toLowerCase() + f.cwd.slice(1))).toEqual({});
expect(await hook(f, f.cwd.replaceAll('\\', '/'))).toEqual(OWNED_READ_APPROVAL);
expect(await hook(f, f.cwd[0]!.toLowerCase() + f.cwd.slice(1))).toEqual(OWNED_READ_APPROVAL);
expect((await hook(f, f.cwd + '\\.') as any).hookSpecificOutput?.permissionDecision).toBe('deny');
});
@@ -1465,7 +1465,7 @@ describe('Autoplan ownership in a linked git worktree session', () => {
const entry = path.join(root, '.git', 'worktrees', 'session'); fs.mkdirSync(entry, { recursive: true });
fs.writeFileSync(path.join(entry, 'gitdir'), lower(path.join(f.cwd, '.git')) + '\n');
fs.writeFileSync(path.join(f.cwd, '.git'), `gitdir: ${lower(entry)}\n`);
expect(await run(f, lower(root))).toEqual({});
expect(await run(f, lower(root))).toEqual(OWNED_READ_APPROVAL);
});
test('worktree.useRelativePaths links resolve against each file\'s own directory', async () => {
+3 -2
View File
@@ -39,8 +39,9 @@ function runPs1(dir: string, args: string[], env: Record<string, string | undefi
}
describe('setup.ps1', () => {
test('passes arguments as an array to a constant bash script', () => {
expect(SOURCE).toContain(`& $bash -c 'exec ./setup "$@"' setup @args`);
test('passes arguments NUL-separated through a private file to a constant bash script', () => {
expect(SOURCE).toContain(`& $bash -c 'mapfile -d "" -t argv < "$1"; rm -f "$1"; exec ./setup "\${argv[@]}"' setup $argFile`);
expect(SOURCE).toContain('foreach ($arg in $args) { $writer.Write([string]$arg); $writer.Write([char]0) }');
expect(SOURCE).not.toMatch(/-join|Invoke-Expression|\biex\b|git-bash\.exe/);
expect([...SOURCE].every((c) => c.charCodeAt(0) < 128)).toBe(true);
});