gitoria
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
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- fd4fc028Exercise member status reads with a populated check statemre
- 536ca6f9Allow repository members to read pull workflow APIs with user tokensmre
- 705dd834W49 missionmre
- b554cd5flogmre
- f4c9440ddeploy.sh: tar --hard-dereference for the live data backupmre
- 1a687b15Merge branch 'w48-member-merge'mre
- 166c775fW48 report, logmre
- 1b4623f0Members merge pull requests: API route, button on /pulls and /pulls/N, one shared merge pathmre
- 1075c38cW48 mission, logmre
- 17bdd0d6V37/V39 missions, logmre
- 146de5f8Re-vendor gitoria to Hybriel set-day39 (51e921d7)mre
- e874e44dtests/status-keyed: app token lives 60 s so it outlives the gate's two restartsmre
- 270b8d61deploy.sh: DEPLOY_STOP_START=1 stops, waits for the old pid, then starts (mpackdb freeze, replaces the standby swap)mre
- 3f9235b8project.hl: drop the dummy /pulls/:n component route (hybriel#294 is fixed in day37)mre
- c90daf19Re-vendor gitoria to Hybriel set-day37 (f6b3d45b)mre
- 03b5bb08W39 report to reports/, drop scratch repro, mission + logmre
- 154d333fMerge w39-create-api: POST /api/repos with a user token (#39)mre
- 149dd512Rewrite W39 reportmre
- e5385075Expect 401 for POST /api/repos without a tokenmre
- 1a76055cDocument repository creation APImre