29 lines
1.6 KiB
TypeScript
29 lines
1.6 KiB
TypeScript
import { afterAll, expect, test } from 'bun:test';
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { projectSdkManifests } from '../cli/lib/privacy-files';
|
|
import { listFiles } from '../cli/lib/scan/project';
|
|
import { skipDir } from '../cli/lib/walk-skip';
|
|
|
|
const root = mkdtempSync(join(tmpdir(), 'walk-'));
|
|
afterAll(() => rmSync(root, { recursive: true, force: true }));
|
|
const put = (rel: string, text = 'x') => { mkdirSync(join(root, rel, '..'), { recursive: true }); writeFileSync(join(root, rel), text); };
|
|
|
|
test('dot folders, linked worktrees and SDK folders', () => {
|
|
put('.harness-worktrees/a/src/App.swift');
|
|
put('wt/.git', 'gitdir: /repo/.git/worktrees/wt\n');
|
|
put('wt/src/App.swift');
|
|
put('src/App.swift');
|
|
put('ios/Pods/Some/PrivacyInfo.xcprivacy', '<plist><dict/></plist>');
|
|
expect(skipDir(root, join(root, '.harness-worktrees'), '.harness-worktrees')).toBe(true);
|
|
expect(skipDir(root, join(root, 'wt'), 'wt')).toBe(true);
|
|
expect(skipDir(root, join(root, 'src'), 'src')).toBe(false);
|
|
expect(skipDir(root, join(root, 'ios', 'Pods'), 'Pods')).toBe(false);
|
|
const files = listFiles(root);
|
|
expect(files).toContain('src/App.swift');
|
|
expect(files.some(f => f.startsWith('.harness-worktrees/') || f.startsWith('wt/'))).toBe(false);
|
|
// worktree copies would add their SDK manifests a second time
|
|
put('.wt-head/ios/Pods/Some/PrivacyInfo.xcprivacy', '<plist><dict/></plist>');
|
|
expect(projectSdkManifests(root).map(m => m.manifest.path)).toEqual(['ios/Pods/Some/PrivacyInfo.xcprivacy']);
|
|
});
|