jukebox
All repositories: gitoria
2.8 KB
import http from 'node:http';import net from 'node:net';import { spawn } from 'node:child_process';import { mkdir, writeFile, copyFile } from 'node:fs/promises';import path from 'node:path';import { fileURLToPath } from 'node:url';const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');const bin = process.env.HL_BIN || path.join(root, 'native/zig-out/bin/hybriel');const work = process.env.TMPDIR;if (!work) throw new Error('set TMPDIR to scratch');const sockets = new Set();const web = http.createServer((req, res) => {const code = Number(req.url.slice(1));res.writeHead(code, { 'content-type': 'application/json', date: 'fixed', connection: 'close' });res.end(JSON.stringify({ code }));});const slow = net.createServer(s => { sockets.add(s); s.on('close', () => sockets.delete(s)); });function listen(s, port) { return new Promise((r, j) => { s.once('error', j); s.listen(port, '127.0.0.1', r); }); }function run(args) {return new Promise((resolve, reject) => {const p = spawn(args[0], args.slice(1), { cwd: root, env: process.env });let out = '', err = '';p.stdout.on('data', s => out += s); p.stderr.on('data', s => err += s);p.on('error', reject); p.on('close', code => code ? reject(new Error(`${args.join(' ')} exit ${code}\n${out}${err}`)) : resolve(out));});}try {const probe = net.createServer(); await listen(probe, 32262); await new Promise(r => probe.close(r));await listen(web, 32260); await listen(slow, 32261);const fixture = path.join(root, 'plugins/fetch/tests/try_fetch.hl');const native = await run([bin, fixture]);await run([bin, '--native', fixture, '-o', path.join(work, 'try-fetch')]);const compiled = await run([path.join(work, 'try-fetch')]);const jsdir = path.join(work, 'try-fetch-js'); await mkdir(jsdir, { recursive: true });await writeFile(path.join(jsdir, 'package.json'), '{"type":"module"}');await run([bin, '--js', '--entry', fixture, '-o', path.join(jsdir, 'probe.mjs')]);await writeFile(path.join(jsdir, 'hl-runtime.js'), await run([bin, '--js-runtime']));await mkdir(path.join(jsdir, 'hl-modules'), { recursive: true });await copyFile(path.join(root, 'plugins/fetch/server.js'), path.join(jsdir, 'hl-modules/fetch.js'));const js = await run(['node', path.join(jsdir, 'probe.mjs')]);if (native !== compiled || native !== js) throw new Error(`different answers\nrun:${native}\nnative:${compiled}\njs:${js}`);if (!native.includes('connection refused') || !native.includes('timed out') || !native.includes('true true true true true true {"code":200} 200') || !native.includes('true true true true true true {"code":404} 404')) throw new Error(native);console.log('PASS 4 scenarios, identical run/native/JS answers\n' + native);} finally {for (const s of sockets) s.destroy();await Promise.all([web, slow].map(s => new Promise(r => s.listening ? s.close(r) : r())));}
Branches
Latest commits
- 1fecd6a7Merge branch 'records-day39' into mainJukebox
- d6b3e068|||PR Records: day39 live (PR #2), mission 011 PR step, statusmre
- 5fa19e89Merge branch 'day39' into mainJukebox
- cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmre
- f3614c9bRe-vendor to Hybriel day39 (51e921d7, bin 6b481aa7)mre
- 9f5c6532Merge branch 'status-22-pr' into mainJukebox
- 5838d6c7|||PR STATUS: #22 pending decision, PR-only rulemre
- 29d2029cRecords: PR-only rule (Kunibert)mre
- adacb0abRecords: neutral ticket rule, #22 decision recordedmre
- b2d6f121Records: #308 hold liftedmre
- 7ab67533Records: day39 on hold (hybriel#308)mre
- 22f21739Records: note rebase before mergemre
- f7368ea3Records: mission 011 day39, waits for lisbethmre
- 9515d2cdRecords: jb20 livemre
- 019f6601ui gate: comment names the open bug components#27 (workaround, not fixed)mre
- 277a2722README: provenance linemre
- 4169ca6aREADME: sync pinmre
- a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mre
- f7936c20Lists keep their scroll position across a reload (jukebox#20): per-list offsets in storage/ui.json, gate jb20mre
- d67906devirtual-list and icons from components.hybriel e5b98ec (centerId, scrollTop, onScroll)mre