diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa9702f..4430700 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,7 @@ jobs: - macos-latest - ubuntu-latest version: - - "1.28.1" + - "1.28" - "1.x" host_version: - vim: "v9.0.0472" diff --git a/denops_test/runner.ts b/denops_test/runner.ts index 1f58878..e3feb41 100644 --- a/denops_test/runner.ts +++ b/denops_test/runner.ts @@ -5,7 +5,7 @@ export type RunMode = "vim" | "nvim"; /** Runner option */ export interface RunOptions - extends Omit { + extends Omit { verbose?: boolean; } @@ -16,19 +16,20 @@ export function run( mode: RunMode, cmds: string[], options: RunOptions = {}, -): Deno.Process { - const cmd = [...buildArgs(mode), ...cmds.flatMap((c) => ["-c", c])]; +): Deno.ChildProcess { + const [cmd, args] = buildArgs(mode); + args.unshift(...cmds.flatMap((c) => ["-c", c])); if (options.verbose) { - cmd.unshift("--cmd", "redir >> /dev/stdout"); + args.unshift("--cmd", "redir >> /dev/stdout"); } - const proc = Deno.run({ - cmd, + const command = new Deno.Command(cmd, { + args, env: options.env, stdin: "piped", stdout: options.verbose ? "inherit" : "null", stderr: options.verbose ? "inherit" : "null", }); - return proc; + return command.spawn(); } /** @@ -44,28 +45,17 @@ export function isRunMode(mode: string): mode is RunMode { } } -function buildArgs(mode: RunMode): string[] { +function buildArgs(mode: RunMode): [string, string[]] { switch (mode) { case "vim": return [ VIM_EXECUTABLE, - "-u", - "NONE", - "-i", - "NONE", - "-n", - "-N", - "-X", - "-e", - "-s", + ["-u", "NONE", "-i", "NONE", "-n", "-N", "-X", "-e", "-s"], ]; case "nvim": return [ NVIM_EXECUTABLE, - "--clean", - "--embed", - "--headless", - "-n", + ["--clean", "--embed", "--headless", "-n"], ]; } } diff --git a/denops_test/with.ts b/denops_test/with.ts index e6d015a..376ec9f 100644 --- a/denops_test/with.ts +++ b/denops_test/with.ts @@ -100,10 +100,9 @@ export async function withDenops( }, ); } finally { - proc.stdin?.close(); - await killProcess(proc); - await proc.status(); - proc.close(); + proc.stdin.close(); + proc.kill(); + await proc.status; conn.close(); listener.close(); } @@ -123,20 +122,3 @@ async function newDenopsImpl( const { DenopsImpl } = await import(url.href); return new DenopsImpl(pluginName, meta, session); } - -async function killProcess(proc: Deno.Process): Promise { - if (Deno.build.os === "windows") { - // Signal API in Deno v1.14.0 on Windows - // does not work so use `taskkill` for now - const p = Deno.run({ - cmd: ["taskkill", "/pid", proc.pid.toString(), "/F"], - stdin: "null", - stdout: "null", - stderr: "null", - }); - await p.status(); - p.close(); - } else { - proc.kill("SIGTERM"); - } -}