test(boot): keep required fixture failures fatal

This commit is contained in:
Turtle authored and turtle1999 committed 2026-09-11 12:47:46 +08:00
1 parent bd4cfc7c46
commit fbcad258ad
2 files changed
+20 -4

No files matched your search

@@ -32,6 +32,10 @@ const binScript = fileURLToPath(new URL('../../../../../../packages/test-support
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
// The resumed-agent fixture in the shared config resumes exactly this id.
const sessionId = SessionId('workspace-context-resume')
const fixtureEnv = {
DSH_SNAPSHOT_FILE: replayFixture,
DSH_LOADER_SMOKE_REQUIRED_ENTRY_ID: 'resumed-agent',
}
/** Persist one session with the given header version and events, returning its log path. */
async function seedSession(root: string, cwd: string, version: number, events: SessionEvent[]): Promise<string> {
@@ -84,7 +88,7 @@ describe('session format guard through the assembled app', () => {
configPath,
binArgs: [configPath, 'Continue the migrated session.'],
tsconfigPath,
env: { DSH_SNAPSHOT_FILE: replayFixture },
env: fixtureEnv,
prepare: async (runCwd) => {
sourcePath = await seedSession(join(runCwd, '.sessions'), runCwd, 0, closedTurn())
source = await readFile(sourcePath)
@@ -124,7 +128,7 @@ describe('session format guard through the assembled app', () => {
configPath,
binArgs: [configPath, 'Try to resume.'],
tsconfigPath,
env: { DSH_SNAPSHOT_FILE: replayFixture },
env: fixtureEnv,
expectedExitCode: 1,
prepare: async (runCwd) => {
sessionPath = await seedSession(join(runCwd, '.sessions'), runCwd, SESSION_FORMAT_VERSION + 99, closedTurn())
@@ -151,7 +155,7 @@ describe('session format guard through the assembled app', () => {
configPath,
binArgs: [configPath, 'Try to resume.'],
tsconfigPath,
env: { DSH_SNAPSHOT_FILE: replayFixture },
env: fixtureEnv,
expectedExitCode: 1,
prepare: async (runCwd) => {
sourcePath = generationLogPath(join(runCwd, '.sessions'), runCwd, sessionId, 2, 'none')
@@ -197,7 +201,7 @@ describe('session format guard through the assembled app', () => {
configPath,
binArgs: [configPath, 'Try to resume.'],
tsconfigPath,
env: { DSH_SNAPSHOT_FILE: replayFixture },
env: fixtureEnv,
expectedExitCode: 1,
prepare: async (runCwd) => {
sessionPath = await seedSession(join(runCwd, '.sessions'), runCwd, SESSION_FORMAT_VERSION, [
@@ -8,6 +8,8 @@ import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { bootProductionProfile } from './production-profile.ts'
const NAME = 'headless-test-driver'
const REQUIRED_ENTRY_ENV = 'DSH_LOADER_SMOKE_REQUIRED_ENTRY_ID'
const FIBER_ACTIVE = 2
const [configPath, ...taskParts] = process.argv.slice(2)
if (configPath === undefined || taskParts.length === 0 || taskParts.every(part => part.trim() === '')) {
throw new Error(`${NAME}: expected <config-path> <task...>`)
@@ -22,6 +24,16 @@ try {
profile: 'headless',
overlayPaths: [resolveConfigPath(configPath, undefined)],
})
const requiredEntryId = process.env[REQUIRED_ENTRY_ENV]
if (requiredEntryId !== undefined) {
const entry = [...ctx.loader.entries()].find(candidate => candidate.options.id === requiredEntryId)
if (entry === undefined) throw new Error(`${NAME}: required fixture entry not found: ${requiredEntryId}`)
if (entry.fiber === undefined) throw new Error(`${NAME}: required fixture entry failed to import: ${requiredEntryId}`)
await entry.fiber.await()
if (entry.fiber.state !== FIBER_ACTIVE) {
throw new Error(`${NAME}: required fixture entry did not activate: ${requiredEntryId}`)
}
}
const result = await runFixtureTurn(ctx, {
task: taskParts.join(' '),
onEvent: (sessionId: string, event: SessionEvent) => {