check / scan: project walks skip dot folders, worktrees and git-ignored output, no stat per entry (244 s -> 46 s on a big game repo)
This commit is contained in:
parent
f2d7beb7ce
commit
164ba390dd
6 changed files with 106 additions and 30 deletions
29
tests/walk-skip.test.ts
Normal file
29
tests/walk-skip.test.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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']);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue