launch.spec.ts 1.3 KB

12345678910111213141516171819202122232425
  1. import { expect, it } from 'vitest'
  2. import type { FileSystem } from '@deepseek-ai/dsh-fs'
  3. import { bootstrapArgs } from '../src/launch.ts'
  4. it('uses an explicit installed bootstrap without pretending it maps the host file', () => {
  5. const fs = { processPathFromHostPath: () => { throw new Error('must not map') } } as unknown as FileSystem
  6. expect(bootstrapArgs(fs, { bootstrapPath: '/remote/process.js' }, 2048)).toEqual(['/remote/process.js', '2048'])
  7. })
  8. it('fails when the execution world cannot read the source bootstrap', () => {
  9. const fs = { processPathFromHostPath: () => undefined } as unknown as FileSystem
  10. expect(() => bootstrapArgs(fs, {}, 2048)).toThrow('unavailable in the subprocess execution world')
  11. })
  12. it('selects the private packaged bootstrap through the existing executable', () => {
  13. const prior = Object.getOwnPropertyDescriptor(process, 'pkg')
  14. try {
  15. Object.defineProperty(process, 'pkg', { configurable: true, value: {} })
  16. const fs = { processPathFromHostPath: () => { throw new Error('pkg does not expose a host bootstrap file') } } as unknown as FileSystem
  17. expect(bootstrapArgs(fs, {}, 2048)).toEqual(['2048'])
  18. } finally {
  19. if (prior === undefined) Reflect.deleteProperty(process, 'pkg')
  20. else Object.defineProperty(process, 'pkg', prior)
  21. }
  22. })