launch.test.ts 692 B

12345678910111213141516171819202122
  1. import { describe, expect, test } from "bun:test"
  2. import fs from "fs/promises"
  3. import path from "path"
  4. import { spawn } from "../../src/lsp/launch"
  5. import { tmpdir } from "../fixture/fixture"
  6. describe("lsp.launch", () => {
  7. test("spawns cmd scripts with spaces on Windows", async () => {
  8. if (process.platform !== "win32") return
  9. await using tmp = await tmpdir()
  10. const dir = path.join(tmp.path, "with space")
  11. const file = path.join(dir, "echo cmd.cmd")
  12. await fs.mkdir(dir, { recursive: true })
  13. await Bun.write(file, "@echo off\r\nif %~1==--stdio exit /b 0\r\nexit /b 7\r\n")
  14. const proc = spawn(file, ["--stdio"])
  15. expect(await proc.exited).toBe(0)
  16. })
  17. })