tools: test nginx, generated tile fixtures and the tile group (#24)

This commit is contained in:
2026-11-15 12:30:51 +01:00
parent 669e47e1ba
commit 30512127b0
8 changed files with 859 additions and 5 deletions
+5 -3
View File
@@ -61,23 +61,25 @@ async function waitForHealth(handle) {
}
// Starts the server and waits for /healthz. Resolves to a handle; stopServer() tears it down.
// `defines` selects a build variant (e.g. a -d:leakfault build), `env` extra environment for it.
// `defines` selects a build variant (e.g. a -d:leakfault build), `env` extra environment for it,
// `publicOrigin` overrides the configured origin (a test nginx in front of the server).
export async function startServer(opts = {}) {
const ownStateDir = opts.stateDir === undefined
const stateDir = opts.stateDir ?? makeStateDir()
const args = opts.args ?? []
const bin = buildServer({ defines: opts.defines })
const port = opts.port ?? await freePort()
const publicOrigin = opts.publicOrigin ?? baseUrl(port)
refuseLivePort(port)
fs.mkdirSync(stateDir, { recursive: true })
const logPath = path.join(stateDir, 'server.log')
const logFd = fs.openSync(logPath, 'a')
const child = spawn(bin, [`--port=${port}`, `--state-dir=${stateDir}`,
`--public-origin=${baseUrl(port)}`, ...args],
`--public-origin=${publicOrigin}`, ...args],
{ cwd: projectRoot, stdio: ['ignore', logFd, logFd],
env: { ...process.env, ...(opts.env ?? {}) } })
const handle = {
port, origin: baseUrl(port), stateDir, dbPath: path.join(stateDir, 'state.db'),
port, origin: baseUrl(port), publicOrigin, stateDir, dbPath: path.join(stateDir, 'state.db'),
logPath, child, log: () => fs.readFileSync(logPath, 'utf8'),
}
try {