gitoria
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
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- ffb60746|||PR close and reopen pull requests (#56)mre
- fe209ffeMerge branch 'w56-owner-members' into mainGitoria
- fa0754c8|||PR repository owner transfer and members API (#55)mre
- 8862e537Merge branch 'w55-rename-org' into mainGitoria
- 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
- 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
- 499f25f2Review fixes for the Settings organization move (#53)mre
- ed3b922b|||PR move a repository into an organization in Settings (#53)mre
- 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
- 9f7ce8d8Preserve rename compatibility and live page titlesmre
- c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
- ce08920dMerge branch 'w52c-header-phone' into mainGitoria
- 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
- e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
- c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
- 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
- 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
- 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
- 155861f6Merge branch 'w52-person-approval' into mainGitoria
- b5435de8|||PR person approvals: second Kunibert round (#52)mre