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
- d7b5e780|||PR Records 2026-11-24 (2): live day72, PR #19 merge, #10 newsmre
- 43b564dbMerge branch 'records-1124b' into mainJukebox
- fa86b08c|||PR Records 2026-11-24: LOG, STATUS, missions 020-023mre
- 0a2ae3daMerge remote-tracking branch 'origin/records-1123' into records-1124mre
- 9a48cfcaMerge branch 'vendor-theme' into mainJukebox
- 170d3735Merge branch 'code-order-2' into mainJukebox
- 3f1918a7|||PR Re-sync layouts theme 4099e64 with Segoe UI firstmre
- 2e7f6a43Vendor virtual-list 489afcf from components.hybrielmre
- 0ba85799Merge branch 'reset-classes' into mainJukebox
- 502eeed5jukebox#20: vendor virtual-list initial resetKey baseline fixmre
- 6d5ce287|||PR jukebox#9 Centralize songs table reads and writes in db.hlmre
- dcca21abjukebox#8 Move copies and queue logic into their topicsmre
- 3b76651cjukebox#20: update virtual-list README pin and resetKey optionsmre
- bc09e1e8|||PR jukebox#20: reset virtual lists through resetKey (partial validation)mre
- a3796dc5Records: live step waits for idlemre
- 3b158e16Records: merges of #9 and #11mre
- 27204167Merge main into records-1123mre
- 10f8a8c8Merge branch 'code-order' into mainJukebox
- 204fc828Merge branch 'day72' into mainJukebox
- 8e8d0e2b|||PR Records: PROCEDURES.md, missions 016-019, GO 2026-11-23mre