gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchmain4099e64aMerge branch 'font-segoe-ui' into mainAtlasmain/plugins/fs/tests/exclusive-create.mjs

2.5 KB

  1. // A barrier releases 16 independent processes against one absent path.
  2. import { spawn, spawnSync } from 'node:child_process';
  3. import { mkdtempSync, writeFileSync, existsSync, readFileSync, rmSync } from 'node:fs';
  4. import { join, resolve } from 'node:path';
  5. import assert from 'node:assert/strict';
  6. const root = resolve(import.meta.dirname, '../../..');
  7. const bin = process.env.HL_BIN || join(root, 'native/zig-out/bin/hybriel');
  8. const work = mkdtempSync(join(process.env.TMPDIR || '/tmp', 'hl-exclusive-'));
  9. const children = [];
  10. try {
  11. const src = join(work, 'claim.hl');
  12. writeFileSync(src, `import { createFile, exists } from 'hl:fs'
  13. import { args } from 'hl:proc'
  14. import { sleep } from 'hl:time'
  15. a = args()
  16. createFile(a[0] + '.ready.' + a[1], '')
  17. while (!exists(a[0] + '.go')) { sleep(0.005) }
  18. console.log(createFile(a[0], a[1]))
  19. `);
  20. const native = join(work, 'claim');
  21. const built = spawnSync(bin, ['--native', src, '-o', native], { encoding: 'utf8' });
  22. assert.equal(built.status, 0, `${built.error || ""}${built.stdout || ""}${built.stderr || ""}`);
  23. for (const engine of ['run', 'native']) {
  24. const path = join(work, engine);
  25. const promises = Array.from({ length: 16 }, (_, i) => {
  26. const child = spawn(engine === 'run' ? bin : native, engine === 'run' ? [src, path, String(i)] : [path, String(i)]);
  27. children.push(child);
  28. return new Promise((resolve, reject) => {
  29. let output = '';
  30. child.stdout.on('data', b => { output += b; });
  31. child.stderr.on('data', b => { output += b; });
  32. child.on('error', reject);
  33. child.on('close', code => resolve({ code, output: output.trim(), i }));
  34. });
  35. });
  36. const deadline = Date.now() + 30000;
  37. while (!Array.from({ length: 16 }, (_, i) => existsSync(path + '.ready.' + i)).every(Boolean)) {
  38. assert.ok(Date.now() < deadline, 'workers did not reach barrier');
  39. await new Promise(r => setTimeout(r, 20));
  40. }
  41. writeFileSync(path + '.go', '');
  42. const answers = await Promise.all(promises);
  43. for (const a of answers) { assert.equal(a.code, 0, a.output); assert.match(a.output, /^(true|false)$/); }
  44. const winners = answers.filter(a => a.output === 'true');
  45. assert.equal(winners.length, 1);
  46. assert.equal(readFileSync(path, 'utf8'), String(winners[0].i));
  47. console.log(`exclusive-create ${engine}: 1/16 won, winner content preserved`);
  48. }
  49. } finally {
  50. for (const c of children) if (c.exitCode === null) c.kill('SIGKILL');
  51. await Promise.all(children.filter(c => c.exitCode === null).map(c => new Promise(r => c.once('close', r))));
  52. rmSync(work, { recursive: true, force: true });
  53. }

Branches

Latest commits

  • 4099e64aMerge branch 'font-segoe-ui' into mainAtlas
  • e14fb795|||PR Theme font: Segoe UI first (his choice 2026-11-19)Atlas
  • 44071d2cMerge branch 'hl-standard-5' into mainAtlas
  • 5ea64202|||PR Gate: count the new-tab check's console errors tooAtlas
  • 2752ceddMerge branch 'hl-standard-4' into mainAtlas
  • ac552b81|||PR Gate: keyboard (Tab/Enter/Space) and Back/Forward/reload/new-tab checks (HL-STANDARD F5, F21)Atlas
  • 8cddcaa9Merge branch 'hl-standard-2' into mainAtlas
  • 2b480a64|||PR Type the route parameter of main-menu build (HL-STANDARD L10)Atlas
  • ab54a39dMerge branch 'hl-standard' into mainAtlas
  • 04d36fcf|||PR Type function parameters and drop unneeded let (HL-STANDARD L2, L10)Atlas
  • 220c8fa4Merge branch 'readme-audit' into mainAtlas
  • b78fb85a|||PR README matches the codemre
  • 9f351699Preserve comments and nest supported selectors without changing rendered outputmre
  • 97110ad9WIP: nest accepted layout selectors; stopped at startup parse failuremre
  • ce4a0baeKeep caller slot styles whole so minimal shell apps startmre
  • 12cd3992Re-vendor complete Hybriel plugins and runtime to day44mre
  • b05c20feBackup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 8d9ed0b8Re-vendor complete Hybriel plugins and runtime to day39mre
  • ebd00b6cNest caller slot styles in three-panemre
  • 009991efNest caller slot styles in list-firstmre