tracker
All repositories: gitoria
2.1 KB
import assert from 'node:assert/strict';import { mkdtempSync, writeFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs';import { spawnSync } from 'node:child_process';import { join, resolve } from 'node:path';const root = resolve(import.meta.dirname, '../../..');const bin = process.env.HL_BIN || join(root, 'native/zig-out/bin/hybriel');const work = mkdtempSync(join(process.env.TMPDIR, 'listdir-lifetime-'));try {const dir = join(work, 'entries');mkdirSync(dir);for (let i = 0; i < 150; i++) writeFileSync(join(dir, String(i).padStart(64, '0') + '.txt'), 'abc');const expected = readdirSync(dir, { withFileTypes: true }).map(e => e.name);const source = join(work, 'walk.hl');writeFileSync(source, `import { listDir, writeFile } from 'hl:fs'import { args } from 'hl:proc'a = args()let rows = []iterator = listDir(a[0])writeFile(a[0] + '/late.txt', 'late')for (entry of iterator) { rows.push(entry) }console.log(JSON.stringify(rows))let early = ''for (entry of listDir(a[0])) { early = entry.namebreak }console.log(early)`);const native = join(work, 'walk');const build = spawnSync(bin, ['--native', source, '-o', native], { encoding: 'utf8' });assert.equal(build.status, 0, build.stdout + build.stderr);const run = spawnSync(native, [dir], { encoding: 'utf8' });assert.equal(run.status, 0, run.stdout + run.stderr);const [json, first] = run.stdout.trim().split('\n');const rows = JSON.parse(json);assert.deepEqual(rows.map(e => e.name).sort(), expected.sort());for (const e of rows) {assert.equal(e.path, join(dir, e.name));assert.equal(e.type, 'file');assert.equal(e.size, 3);assert.equal(e.mime, 'text/plain');assert.equal(typeof e.chmod, 'number');assert.equal(e.user, process.getuid());assert.equal(e.group, process.getgid());assert.deepEqual(Object.keys(e).sort(), ['chmod', 'group', 'mime', 'name', 'path', 'size', 'type', 'user']);}assert.ok(expected.includes(first) || first === 'late.txt');console.log('listDir: 150 retained eight-field entries survive exhaustion; call-time snapshot and early exit pass');} finally { rmSync(work, { recursive: true, force: true }); }
Branches
Latest commits
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker
- b9c7c3c8Merge branch 'records-dp74' into mainTracker
- 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker
- b1496147Merge branch 'ap61' into mainTracker
- 2047955bMerge branch 'u12-gateports' into mainTracker
- c8da40f3|||PR AP61: re-vendor Hybriel set day61 (source a05af47c, bin a11042e5)Tracker
- 4e018678|||PR deploy.sh: gates use Tracker's ports 8716-8719 and LC_ALL=C; README: 2 backups keptTracker
- 0b86324aMerge branch 'records-dp73' into mainTracker
- 9ce5f59b|||PR records: DP73 live 613ae0e; deploy.sh keeps 2 backupsTracker
- 613ae0ecMerge branch 'bs3' into mainTracker
- 1383264b|||PR BS3: keep shared synchronous sorting fastTracker
- 63e5ba1a|||PR BS3: guard boot imports and share resumable sort buffersTracker
- 310613f1Merge branch 'records-dp72' into mainTracker
- 6f7b61ba|||PR records: deploy-swap fix live, Kunibert findingsTracker
- c41587d2Merge branch 'bs2' into mainTracker
- 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
- 019d5cedMerge branch 'records-1110' into mainTracker
- f88ae8b9|||PR records: day56 toggle live, reviewTracker
- b6b3bb4dMerge branch 'ap56e' into mainTracker
- 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker