mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-16 20:53:57 +08:00
oversize-file-not-read's drift test wrote a 1.4 MB `.js` made of one statement repeated 110k times. Windows Defender's script scan of that freshly written file takes about 54 s on its first read (the viewer's read in the test), so the test always timed out on Windows and its cleanup then hit EPERM on the still open file. A varied 2.4 MB `.js` and a real 2 MB bundle scan in 35 ms and 144 ms, so this is the fixture, not something users hit; the fixture now has a different statement on every line. The mpeg-ts git-path cases build a git repository and index it, the last one twice. At ~100 ms per git process on Windows that is 5–6 s, past vitest's 5 s default; the describe now allows 30 s. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,7 +215,10 @@ describe('MPEG-TS video named .ts is skipped, real TypeScript is indexed (#1910)
|
||||
});
|
||||
});
|
||||
|
||||
describe('a video .ts never stays pending (#1910)', () => {
|
||||
// Each case builds a git repository and indexes it, the last one twice over. On
|
||||
// Windows every git process costs ~100 ms, which puts these cases at 5–6 s there,
|
||||
// past vitest's 5 s default.
|
||||
describe('a video .ts never stays pending (#1910)', { timeout: 30_000 }, () => {
|
||||
const dirs: string[] = [];
|
||||
afterEach(() => { for (const d of dirs.splice(0)) fs.rmSync(d, { recursive: true, force: true }); });
|
||||
const gitProject = (): string => {
|
||||
|
||||
@@ -89,8 +89,17 @@ describe('an unchanged file over the size limit is not reported as drifted (#191
|
||||
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-oversize-drift-'));
|
||||
fs.writeFileSync(path.join(dir, 'app.ts'), 'export function alpha() { return 1; }\n');
|
||||
// 1.4 MB of ordinary text: over the index limit, under the viewer's 8 MB read cap.
|
||||
const line = 'const x = 1;\n';
|
||||
fs.writeFileSync(path.join(dir, 'big.js'), line.repeat(Math.ceil((1.4 * 1024 * 1024) / line.length)));
|
||||
// Each line differs: Windows Defender's script scan of a freshly written `.js`
|
||||
// made of one statement repeated 110k times takes close to a minute on the
|
||||
// first read, so the viewer's read below blew the test timeout there. Real
|
||||
// code of the same size is scanned in milliseconds.
|
||||
const line = 'const last = 0;\n';
|
||||
const lines: string[] = [];
|
||||
for (let size = 0, i = 0; size < 1.4 * 1024 * 1024; i++) {
|
||||
lines.push(`const x${i} = ${i};\n`);
|
||||
size += lines[i]!.length;
|
||||
}
|
||||
fs.writeFileSync(path.join(dir, 'big.js'), lines.join(''));
|
||||
const cg = await CodeGraph.init(dir, { index: true });
|
||||
try {
|
||||
const record = cg.getFiles().find((f) => f.path === 'big.js')!;
|
||||
|
||||
Reference in New Issue
Block a user