Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 12 additions & 101 deletions scripts/architecture-baseline.json

Large diffs are not rendered by default.

46 changes: 10 additions & 36 deletions src/__tests__/cli-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
envBooleanValue as cliEnvBooleanValue,
resolvePerModeEnv as cliResolvePerModeEnv,
} from "../cli.js"
import { runMain } from "../test-runner.js"

async function testPerModeOverrideWins(): Promise<void> {
const env = { HEADLESSCODE_FOO: "global", HEADLESSCODE_FOO__CODE: "per-mode" }
Expand Down Expand Up @@ -60,40 +61,13 @@ async function testCliReexportsTheLeaf(): Promise<void> {
assert.equal(cliEnvBoolean, envBoolean)
}

async function runOne(name: string, fn: () => Promise<void>): Promise<boolean> {
try {
await fn()
console.log(` ok ${name}`)
return true
} catch (error) {
console.error(` FAIL ${name}`)
if (error instanceof Error) console.error(error.stack ?? error)
else console.error(String(error))
return false
}
}

async function main(): Promise<void> {
const tests: Array<[string, () => Promise<void>]> = [
["per-mode override wins", testPerModeOverrideWins],
["global falls back", testGlobalFallsBack],
["mode slug normalization", testModeSlugNormalization],
["missing is undefined", testMissingIsUndefined],
["env boolean values", testEnvBooleanValues],
["cli re-exports the leaf", testCliReexportsTheLeaf],
]
let failed = 0
for (const [name, fn] of tests) {
if (!(await runOne(name, fn))) failed++
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} cli-env tests passed`)
}
const tests: Array<[string, () => Promise<void>]> = [
["per-mode override wins", testPerModeOverrideWins],
["global falls back", testGlobalFallsBack],
["mode slug normalization", testModeSlugNormalization],
["missing is undefined", testMissingIsUndefined],
["env boolean values", testEnvBooleanValues],
["cli re-exports the leaf", testCliReexportsTheLeaf],
]

main().catch((error) => {
console.error("Test runner crashed:", error)
process.exit(1)
})
runMain("cli-env", tests)
25 changes: 2 additions & 23 deletions src/budget/__tests__/budget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
type SessionBudget,
} from "../budget.js"
import type { PricingTable } from "../cost.js"
import { runMain } from "../../test-runner.js"

// Cheap model for deterministic math: $1/1M in, $2/1M out → 1000 in + 1000 out
// = (1000*1 + 1000*2)/1e6 = $0.003 per call.
Expand Down Expand Up @@ -346,26 +347,4 @@ const tests: Array<[string, () => Promise<void>]> = [
["session: iterations cap trips before the next LLM call", testSessionBudgetIterationsCap],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} budget tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("budget", tests)
25 changes: 2 additions & 23 deletions src/budget/__tests__/concurrency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { saveWatcherState, type WatcherState } from "../../watcher/state.js"
import { watchIssues, type SpawnBatch, type WatcherConfig } from "../../watcher/watch.js"
import { loadWatcherState } from "../../watcher/state.js"
import type { GhClient, GitHubIssue } from "../../watcher/github.js"
import { runMain } from "../../test-runner.js"

const SILENT = new Logger({ level: "silent" })

Expand Down Expand Up @@ -260,26 +261,4 @@ const tests: Array<[string, () => Promise<void>]> = [
["watcher: pre-existing running fleet at cap -> all new issues deferred", testWatcherGlobalCapRespectsActiveFleet],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} concurrency tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("concurrency", tests)
25 changes: 2 additions & 23 deletions src/budget/__tests__/cost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
type EndpointPricingEntry,
type PricingTable,
} from "../cost.js"
import { runMain } from "../../test-runner.js"

/**
* Regression test for a real incident (2026-08-01): `deepseek/deepseek-v4-flash`
Expand Down Expand Up @@ -356,26 +357,4 @@ const tests: Array<[string, () => Promise<void>]> = [
["mergeLivePrice overrides the hardcoded entry, feeds estimateCost", testMergeLivePriceOverridesDefaults],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} cost tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("cost", tests)
25 changes: 2 additions & 23 deletions src/checkpoints/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as path from "node:path"

import { checkpointsMain, parseCheckpointsArgs } from "../cli.js"
import { createCheckpointService } from "../service.js"
import { runMain } from "../../test-runner.js"

async function tmpRepo(prefix = "hc-ckpt-cli-"): Promise<string> {
return fs.mkdtemp(path.join(os.tmpdir(), prefix))
Expand Down Expand Up @@ -223,26 +224,4 @@ const tests: Array<[string, () => void | Promise<void>]> = [
["checkpointsMain: diff against the working tree exits 0", testMainDiffAgainstWorkingTree],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? (err.stack ?? err.message) : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} checkpoints CLI tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("checkpoints CLI", tests)
25 changes: 2 additions & 23 deletions src/checkpoints/__tests__/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as os from "node:os"
import * as path from "node:path"

import { createCheckpointService } from "../service.js"
import { runMain } from "../../test-runner.js"

async function mkTmpWorkspace(prefix: string): Promise<string> {
return fs.mkdtemp(path.join(os.tmpdir(), prefix))
Expand Down Expand Up @@ -198,26 +199,4 @@ const tests: Array<[string, () => Promise<void>]> = [
["diff: reports before/after content for a changed file", testDiffReportsChangedFile],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} checkpoints tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("checkpoints", tests)
15 changes: 3 additions & 12 deletions src/cloud/__tests__/docker-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as path from "node:path"

import { DockerSessionProvider } from "../docker-provider.js"
import type { CloudSessionRequest, CommandResult, SessionHandle } from "../provider.js"
import { runSuites } from "../../test-runner.js"

// ─── Docker availability probe ───────────────────────────────────────────────

Expand Down Expand Up @@ -302,18 +303,8 @@ if (probe.ok) {

async function main(): Promise<void> {
console.log(` note: ${dockerNote}`)
let failed = 0
let skipped = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
const failed = await runSuites("docker-provider", tests)
if (!probe.ok) {
skipped = 2
console.log(` SKIP ${skipped} real-daemon test(s) — ${probe.reason}`)
Expand All @@ -322,7 +313,7 @@ async function main(): Promise<void> {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} docker-provider tests passed (${skipped} skipped: no Docker daemon)`)
console.log(` note: ${skipped} skipped (no Docker daemon)`)
}

main().catch((err) => {
Expand Down
25 changes: 2 additions & 23 deletions src/cloud/__tests__/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
type CommandResult,
type SessionHandle,
} from "../provider.js"
import { runMain } from "../../test-runner.js"

async function tmpRepo(): Promise<string> {
return fs.mkdtemp(path.join(os.tmpdir(), "headlesscode-provider-repo-"))
Expand Down Expand Up @@ -188,26 +189,4 @@ const tests: Array<[string, () => Promise<void>]> = [
["HetznerDockerProvider is a documented sketch (not implemented)", testHetznerSketchIsDocumentedNotImplemented],
]

async function main(): Promise<void> {
let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} provider tests passed`)
}

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("provider", tests)
31 changes: 5 additions & 26 deletions src/codeintel/__tests__/call-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as path from "node:path"

import { getCallGraph } from "../call-graph.js"
import { getCodeIntelCache, resetCodeIntelCaches } from "../program.js"
import { runMain } from "../../test-runner.js"

const FIXTURE_A = `import { greet, Greeter } from "./b.js"

Expand Down Expand Up @@ -101,30 +102,8 @@ async function testCallTargetsResolveToDefiningFile(): Promise<void> {
}
}

async function main(): Promise<void> {
const tests: Array<[string, () => Promise<void>]> = [
["call targets resolve to their defining file via the TS checker", testCallTargetsResolveToDefiningFile],
]

let failed = 0
for (const [name, fn] of tests) {
try {
await fn()
console.log(` ok ${name}`)
} catch (err) {
failed++
console.error(` FAIL ${name}`)
console.error(err instanceof Error ? err.stack ?? err.message : String(err))
}
}
if (failed > 0) {
console.error(`\n${failed} test(s) failed`)
process.exit(1)
}
console.log(`\nAll ${tests.length} call-graph tests passed`)
}
const tests: Array<[string, () => Promise<void>]> = [
["call targets resolve to their defining file via the TS checker", testCallTargetsResolveToDefiningFile],
]

main().catch((err) => {
console.error("Test runner crashed:", err)
process.exit(1)
})
runMain("call-graph", tests)
Loading
Loading