components
All repositories: gitoria
3.0 KB
import assert from 'node:assert/strict';import http from 'node:http';import { spawn, spawnSync } from 'node:child_process';import { readlinkSync } from 'node:fs';import { once } from 'node:events';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';const HERE = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(HERE, '../../..');const PORT = Number(process.env.HL_TEST_PORT || 32069);const BIN = process.env.HL_BIN || resolve(ROOT, 'native/zig-out/bin/hybriel');const child = spawn(BIN, [resolve(HERE, 'sse-close.hl')], { cwd: ROOT, env: process.env });let log = '', checks = 0;child.stdout.on('data', d => { log += d; });child.stderr.on('data', d => { log += d; });const streams = [];const sleep = ms => new Promise(r => setTimeout(r, ms));async function waitFor(fn) {for (let i = 0; i < 250; i++) { if (await fn()) return; await sleep(20); }throw new Error('timeout\n' + log);}const get = path => fetch(`http://127.0.0.1:${PORT}${path}`).then(r => r.text());function check(a, b) { assert.deepEqual(a, b); checks++; }async function stream() {const p = { data: '', ended: false };streams.push(p);p.req = http.get(`http://127.0.0.1:${PORT}/stream`, res => {p.res = res;res.on('data', d => { p.data += d; });res.on('end', () => { p.ended = true; });res.on('error', e => { p.error = e; });});p.req.on('error', e => { p.error = e; });await waitFor(() => /data: (\d+)\n\n/.test(p.data));p.id = Number(p.data.match(/data: (\d+)\n\n/)[1]);return p;}try {await waitFor(async () => { try { return await get('/') === '0'; } catch { return false; } });const a = await stream(), b = await stream();check(await get('/'), '2');check(await get(`/alive?id=${a.id}`), 'true');check(await get(`/close?id=${a.id}`), 'true');await waitFor(() => a.ended);check(a.ended, true);check(await get('/'), '1');check(await get(`/alive?id=${a.id}`), 'false');check(await get(`/send?id=${a.id}`), 'false');check(await get(`/close?id=${a.id}`), 'false');check(await get(`/send?id=${b.id}`), 'true');check(await get('/broadcast'), '1');await waitFor(() => b.data.includes('data: broadcast\n\n'));check(b.data, `: connected\n\ndata: ${b.id}\n\ndata: direct\n\ndata: broadcast\n\n`);const c = await stream();check(c.id > Math.max(a.id, b.id), true);check(await get('/'), '2');check(await get(`/send?id=${a.id}`), 'false');check(await get(`/send?id=${c.id}`), 'true');await waitFor(() => c.data.includes('data: direct\n\n'));check(c.data, `: connected\n\ndata: ${c.id}\n\ndata: direct\n\n`);check(await get(`/alive?id=${b.id}`), 'true');console.log(`ok sse-close: ${checks} checks`);} finally {for (const p of streams) { p.res?.destroy(); p.req.destroy(); }if (child.exitCode === null && child.signalCode === null) {assert.equal(readlinkSync(`/proc/${child.pid}/cwd`), ROOT);spawnSync('ss', ['-ltnp', `sport = ${PORT}`]);const stopped = once(child, 'exit'); child.kill('SIGTERM'); await stopped;}}
Branches
- b27b
- mainmain branch
- vendor-day72
- vl27-baseline
- vl27-resetkey
Latest commits
- a06fc778Reset virtual-list window when the host changes resetKeyAtlas
- 3aab598cRe-vendor complete Hybriel day73 set for virtual-list resetAtlas
- 337ca075MD1 gate check measures frames in the page, not milliseconds from outside, and takes the middle load (components#30)mre
- f5f131c5Record AP29 autoplay comparisons and passing gatesmre
- 51c38187Gate media autoplay on first load and after client mountmre
- a3f2223dRecord successful B44 deployment and live proofmre
- 06c1e021Record passing B44 browser rerunmre
- c9861533Record B44 component proof and browser gate blockermre
- 1b7413beIgnore detached media events and space demo option outputsmre
- ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
- df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
- 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
- 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
- 9b872cedRecord IC28 deployment and live icon verificationmre
- 46fefaa7Count the icons entry in the offline home-page checkmre
- c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
- 5e090ffdRecord IC28 review evidence and gate resultsmre
- adfe2c4dAdd shuffle, repeat and repeatOne shared iconsmre
- c96709c8media-player: skip = false and repeat = 'one' options (jukebox#19)mre