mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
|
|
|
|
const configPath = '/tmp/fixture.cordis.yml'
|
|
const tsconfigPath = fileURLToPath(new URL('../../../../tsconfig.json', import.meta.url))
|
|
const fixture = (name: string): string => fileURLToPath(new URL(`./fixtures/${name}.ts`, import.meta.url))
|
|
const canonicalTempPath = (path: string): string => path.replace(/^\/private(?=\/var\/)/, '')
|
|
|
|
describe('runLoaderSmoke', () => {
|
|
it('isolates the process, writes stdin, captures output, and removes the cwd', async () => {
|
|
const result = await runLoaderSmoke({
|
|
label: 'success fixture',
|
|
tempDirPrefix: 'loader-smoke-success-',
|
|
binScript: fixture('success'),
|
|
configPath,
|
|
tsconfigPath,
|
|
env: { LOADER_SMOKE_MARKER: 'present' },
|
|
stdinLines: ['one', 'two'],
|
|
})
|
|
const output = JSON.parse(result.stdout) as {
|
|
configPath: string
|
|
cwd: string
|
|
dshHome: string
|
|
agentsHome: string
|
|
marker: string
|
|
input: string
|
|
}
|
|
expect(output).toMatchObject({
|
|
configPath,
|
|
marker: 'present',
|
|
input: 'one\ntwo\n',
|
|
})
|
|
expect(canonicalTempPath(output.dshHome)).toBe(`${canonicalTempPath(output.cwd)}/.dsh`)
|
|
expect(canonicalTempPath(output.agentsHome)).toBe(`${canonicalTempPath(output.cwd)}/.agents`)
|
|
expect(result.stderr).toContain('fixture stderr')
|
|
expect(existsSync(output.cwd)).toBe(false)
|
|
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
|
|
|
|
it('rejects a non-zero exit with captured diagnostics', async () => {
|
|
await expect(runLoaderSmoke({
|
|
label: 'failure fixture',
|
|
tempDirPrefix: 'loader-smoke-fail-',
|
|
binScript: fixture('fail'),
|
|
configPath,
|
|
tsconfigPath,
|
|
})).rejects.toThrow('failure fixture exited 7. stdout:\n\nstderr:\nfixture failed')
|
|
})
|
|
|
|
it('kills a process at its deadline and reports captured output', async () => {
|
|
await expect(runLoaderSmoke({
|
|
label: 'hanging fixture',
|
|
tempDirPrefix: 'loader-smoke-hang-',
|
|
binScript: fixture('hang'),
|
|
configPath,
|
|
tsconfigPath,
|
|
processTimeoutMs: 100,
|
|
})).rejects.toThrow('hanging fixture did not exit within 0.1s.')
|
|
})
|
|
})
|