gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8580c5d98580c5d9log: theme fix from Atlasmre8580c5d9/plugins/fetch/tests/try-fetch.mjs

2.8 KB

  1. import http from 'node:http';
  2. import net from 'node:net';
  3. import { spawn } from 'node:child_process';
  4. import { mkdir, writeFile, copyFile } from 'node:fs/promises';
  5. import path from 'node:path';
  6. import { fileURLToPath } from 'node:url';
  7. const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
  8. const bin = process.env.HL_BIN || path.join(root, 'native/zig-out/bin/hybriel');
  9. const work = process.env.TMPDIR;
  10. if (!work) throw new Error('set TMPDIR to scratch');
  11. const sockets = new Set();
  12. const web = http.createServer((req, res) => {
  13. const code = Number(req.url.slice(1));
  14. res.writeHead(code, { 'content-type': 'application/json', date: 'fixed', connection: 'close' });
  15. res.end(JSON.stringify({ code }));
  16. });
  17. const slow = net.createServer(s => { sockets.add(s); s.on('close', () => sockets.delete(s)); });
  18. function listen(s, port) { return new Promise((r, j) => { s.once('error', j); s.listen(port, '127.0.0.1', r); }); }
  19. function run(args) {
  20. return new Promise((resolve, reject) => {
  21. const p = spawn(args[0], args.slice(1), { cwd: root, env: process.env });
  22. let out = '', err = '';
  23. p.stdout.on('data', s => out += s); p.stderr.on('data', s => err += s);
  24. p.on('error', reject); p.on('close', code => code ? reject(new Error(`${args.join(' ')} exit ${code}\n${out}${err}`)) : resolve(out));
  25. });
  26. }
  27. try {
  28. const probe = net.createServer(); await listen(probe, 32262); await new Promise(r => probe.close(r));
  29. await listen(web, 32260); await listen(slow, 32261);
  30. const fixture = path.join(root, 'plugins/fetch/tests/try_fetch.hl');
  31. const native = await run([bin, fixture]);
  32. await run([bin, '--native', fixture, '-o', path.join(work, 'try-fetch')]);
  33. const compiled = await run([path.join(work, 'try-fetch')]);
  34. const jsdir = path.join(work, 'try-fetch-js'); await mkdir(jsdir, { recursive: true });
  35. await writeFile(path.join(jsdir, 'package.json'), '{"type":"module"}');
  36. await run([bin, '--js', '--entry', fixture, '-o', path.join(jsdir, 'probe.mjs')]);
  37. await writeFile(path.join(jsdir, 'hl-runtime.js'), await run([bin, '--js-runtime']));
  38. await mkdir(path.join(jsdir, 'hl-modules'), { recursive: true });
  39. await copyFile(path.join(root, 'plugins/fetch/server.js'), path.join(jsdir, 'hl-modules/fetch.js'));
  40. const js = await run(['node', path.join(jsdir, 'probe.mjs')]);
  41. if (native !== compiled || native !== js) throw new Error(`different answers\nrun:${native}\nnative:${compiled}\njs:${js}`);
  42. 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);
  43. console.log('PASS 4 scenarios, identical run/native/JS answers\n' + native);
  44. } finally {
  45. for (const s of sockets) s.destroy();
  46. await Promise.all([web, slow].map(s => new Promise(r => s.listening ? s.close(r) : r())));
  47. }

Branches

Latest commits

  • 8580c5d9log: theme fix from Atlasmre
  • 46823d93log: Apollo budget correctionmre
  • f6d32341log: Apollo on budget and #25 nextmre
  • d7184f53log: batch live, #25 evidencemre
  • 5e25e816log: W61 mergedmre
  • aafe330dTidy: drop evidence JSON (kept in scratch), collapse blank linesmre
  • aca1fda1Merge W61: theme from layouts 17e0f03, Views refer to Style rules (gitoria#37 #27)mre
  • 03cb650blog: W61 theme decisionmre
  • 248bce85Report final style gates, CSS mappings and 136 whole-image comparisonsmre
  • 153c344bRestore organization metadata exposed by the whole-image comparisonmre
  • 917a1465Update status gate assertions for the referenced state rulemre
  • 3cdb02c6Own settings feedback styles and explain connection-state classesmre
  • 00d5d6c4Reference code-entry styles and nest code-browser media and pseudosmre
  • 3c425eddReference PR content styles and explain dynamic state classesmre
  • e46fa222Own shell feedback styles and retain documented selector formsmre
  • c26084c4Reference repository list styles and nest its breakpointmre
  • f3e196b5Document Markdown direct-child selector remaindersmre
  • 70597528Reference pull list rules and explain runtime class predicatesmre
  • 1ce7ac24Reference ticket row and feedback styles from its Viewmre
  • 10cdf54bGive organization repository rows their own Style referencesmre