47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
// Runs every root verify-*.mjs in a child process and reports a summary.
|
|
// Exit code is non-zero if any script fails. Scripts that skip (environmental
|
|
// limitations) count as pass with a note.
|
|
import { readdirSync } from 'node:fs'
|
|
import { spawnSync } from 'node:child_process'
|
|
import { join, dirname } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const root = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
const node = process.execPath
|
|
|
|
const includeRealHost = process.env.DSH_VERIFY_REAL_MCP === '1'
|
|
const names = readdirSync(root)
|
|
.filter((f) => /^verify-.*\.mjs$/.test(f) && (includeRealHost || f !== 'verify-mcp-bridge.mjs'))
|
|
.sort()
|
|
|
|
const results = []
|
|
for (const name of names) {
|
|
const started = Date.now()
|
|
const r = spawnSync(node, [join(root, name)], {
|
|
cwd: root,
|
|
encoding: 'utf8',
|
|
timeout: 5 * 60_000,
|
|
})
|
|
const code = r.status === null ? 1 : r.status
|
|
const out = (r.stdout || '') + (r.stderr || '')
|
|
const tail = out.trimEnd().split('\n').filter(Boolean).slice(-3).join(' | ')
|
|
const skipped = out.split('\n').some((line) => /^SKIP(?:\s|:|$)/.test(line.trim()))
|
|
results.push({ name, code, ms: Date.now() - started, skipped, tail })
|
|
const flag = code === 0 ? (skipped ? 'PASS*' : 'PASS') : 'FAIL'
|
|
console.log(`${flag.padEnd(5)} ${name} (${(results[results.length - 1].ms / 1000).toFixed(1)}s)`)
|
|
if (code !== 0) console.log(' ' + tail.slice(0, 500))
|
|
}
|
|
|
|
const failed = results.filter((r) => r.code !== 0)
|
|
const skippedCount = results.filter((r) => r.skipped).length
|
|
console.log(
|
|
`\n${results.length} scripts: ${results.length - failed.length} passed` +
|
|
(skippedCount ? ` (${skippedCount} with environmental skips)` : '') +
|
|
(failed.length ? `, ${failed.length} FAILED: ${failed.map((f) => f.name).join(', ')}` : ', all green'),
|
|
)
|
|
if (failed.length) {
|
|
console.log('Last output of each failure:')
|
|
for (const f of failed) console.log(' ' + f.name + ': ' + f.tail.slice(0, 300))
|
|
process.exit(1)
|
|
}
|