tracker
All repositories: gitoria
2.5 KB
// A barrier releases 16 independent processes against one absent path.import { spawn, spawnSync } from 'node:child_process';import { mkdtempSync, writeFileSync, existsSync, readFileSync, rmSync } from 'node:fs';import { join, resolve } from 'node:path';import assert from 'node:assert/strict';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 || '/tmp', 'hl-exclusive-'));const children = [];try {const src = join(work, 'claim.hl');writeFileSync(src, `import { createFile, exists } from 'hl:fs'import { args } from 'hl:proc'import { sleep } from 'hl:time'a = args()createFile(a[0] + '.ready.' + a[1], '')while (!exists(a[0] + '.go')) { sleep(0.005) }console.log(createFile(a[0], a[1]))`);const native = join(work, 'claim');const built = spawnSync(bin, ['--native', src, '-o', native], { encoding: 'utf8' });assert.equal(built.status, 0, `${built.error || ""}${built.stdout || ""}${built.stderr || ""}`);for (const engine of ['run', 'native']) {const path = join(work, engine);const promises = Array.from({ length: 16 }, (_, i) => {const child = spawn(engine === 'run' ? bin : native, engine === 'run' ? [src, path, String(i)] : [path, String(i)]);children.push(child);return new Promise((resolve, reject) => {let output = '';child.stdout.on('data', b => { output += b; });child.stderr.on('data', b => { output += b; });child.on('error', reject);child.on('close', code => resolve({ code, output: output.trim(), i }));});});const deadline = Date.now() + 30000;while (!Array.from({ length: 16 }, (_, i) => existsSync(path + '.ready.' + i)).every(Boolean)) {assert.ok(Date.now() < deadline, 'workers did not reach barrier');await new Promise(r => setTimeout(r, 20));}writeFileSync(path + '.go', '');const answers = await Promise.all(promises);for (const a of answers) { assert.equal(a.code, 0, a.output); assert.match(a.output, /^(true|false)$/); }const winners = answers.filter(a => a.output === 'true');assert.equal(winners.length, 1);assert.equal(readFileSync(path, 'utf8'), String(winners[0].i));console.log(`exclusive-create ${engine}: 1/16 won, winner content preserved`);}} finally {for (const c of children) if (c.exitCode === null) c.kill('SIGKILL');await Promise.all(children.filter(c => c.exitCode === null).map(c => new Promise(r => c.once('close', r))));rmSync(work, { recursive: true, force: true });}
Branches
Latest commits
- 78b39f1bMerge hm56-rows: tracker#56 list builders insert oncemre
- 6da612fclog: T36A tool defectmre
- 08e55255log: HM56 done, T36A startedmre
- 91bcdf0eAvoid per-row list copies and reproduce keyed-row blockersmre
- 5fd2ac75status: #36 GOmre
- 0d253b45mission: T36Amre
- 2aa22d23log: #36 GOmre
- 833aee2flog: #50 closed, HM56 startedmre
- ac58c1e5mission: HM56mre
- 58979c0clog: HM54 held for decision, DP65 startedmre
- bb2ebc67log: #64 live, #53 mergedmre
- 27cde42fMerge hm53-dom: tracker#53 inputs bound to membersmre
- 2156cc7flog: HM54 reviewmre
- 9fb82efclog: HM54 gap, fill continuesmre
- b632eb8dlog: HM53 done, HM54 startedmre
- ccb1a263tracker#53: bind editor drafts and use key event focus targetmre
- 3356fcfclog: #52 blocked, HM53 startedmre
- 833dcfc9Merge hm52-search: report only, tracker#52 blocked by framework gapmre
- 73010cc0HM52: report replace-navigation search draft regressionmre
- 1742e92bstatus: DP64 and HM52 runningmre