| 1 | #!/usr/bin/env node |
| 2 | import { spawnSync } from "node:child_process" ; |
| 3 | import { mkdirSync, writeFileSync } from "node:fs" ; |
| 4 | import { resolve } from "node:path" ; |
| 5 | |
| 6 | const root = resolve(import.meta.dirname, "../.." ); |
| 7 | const stamp = new Date().toISOString().replace(/[-:]/g, "" ).replace(/\.\d{3}Z$/, "Z" ); |
| 8 | const artifactDir = resolve(process.env.CONFORMANCE_ARTIFACTS ?? resolve(root, "artifacts/conformance" ), stamp); |
| 9 | mkdirSync(artifactDir, { recursive: true }); |
| 10 | const env = { ...process.env, RELAY_URL: process.env.RELAY_URL ?? "ws://127.0.0.1:7447" }; |
| 11 | writeFileSync(resolve(artifactDir, "environment.txt" ), Object.entries({ RELAY_URL: env.RELAY_URL, NODE: process.version, PLATFORM: process.platform, ARCH: process.arch }).map(([key, value]) => `${key}=${value}` ).join("\n" ) + "\n" ); |
| 12 | const result = spawnSync(process.execPath, [resolve(root, "node_modules/vitest/vitest.mjs" ), "run" , "--config" , resolve(root, "scripts/conformance/vitest.config.mts" ), ...process.argv.slice(2)], { cwd: root, env, encoding: "utf8" , stdio: ["inherit" , "pipe" , "pipe" ] }); |
| 13 | process.stdout.write(result.stdout ?? "" ); |
| 14 | process.stderr.write(result.stderr ?? "" ); |
| 15 | writeFileSync(resolve(artifactDir, "stdout.log" ), result.stdout ?? "" ); |
| 16 | writeFileSync(resolve(artifactDir, "stderr.log" ), result.stderr ?? "" ); |
| 17 | writeFileSync(resolve(artifactDir, "status" ), `${result.status ?? 1}\n` ); |
| 18 | console.error(`conformance artifacts: ${artifactDir}` ); |
| 19 | process.exit(result.status ?? 1); |