source-launch.compat.spec.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { fileURLToPath } from 'node:url'
  2. import { execa } from 'execa'
  3. import { describe, expect, it } from 'vitest'
  4. /**
  5. * Keyless smoke for the SOURCE `dsh` launcher: run `apps/cli/src/bin.ts`
  6. * with the exact production launch vector (`node --import tsx/esm`, the same
  7. * shape as `bin/dsh` and the root `dsh`/`demo:tui`/`demo:web` scripts) and
  8. * assert the piped-stdio TTY refusal. The Node compatibility matrix runs this
  9. * WHOLE file, so a Node release changing module hooks or TypeScript handling
  10. * breaks this gate instead of every developer's `pnpm dsh`; the built-bin
  11. * suite covers the published `lib/` entry, not this source chain.
  12. */
  13. const repoRoot = fileURLToPath(new URL('../../../', import.meta.url))
  14. const dshSourceBin = 'apps/cli/src/bin.ts'
  15. describe('dsh SOURCE launcher (node --import tsx/esm)', () => {
  16. it('boots the source entry and refuses pipes LOUD (non-zero exit + stderr)', async () => {
  17. const result = await execa(process.execPath, ['--import', 'tsx/esm', dshSourceBin], {
  18. cwd: repoRoot,
  19. input: '',
  20. timeout: 25_000,
  21. killSignal: 'SIGKILL',
  22. reject: false,
  23. })
  24. if (result.timedOut) {
  25. throw new Error(`dsh source launch did not exit within 25s. stdout:\n${result.stdout}\nstderr:\n${result.stderr}`)
  26. }
  27. expect(result.exitCode).not.toBe(0)
  28. expect(result.stderr).toContain('requires stdin and stdout to be interactive TTYs')
  29. expect(result.stderr).toContain('dsh -p')
  30. // The refusal happens before any plugin mounts: stdout stays silent.
  31. expect(result.stdout).toBe('')
  32. }, 30_000)
  33. })