diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index ea8901c3..5736498b 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -2,6 +2,7 @@ name: deno env: DENO_VERSION: 1.x + DENOPS_PATH: "./" on: schedule: diff --git a/denops/@denops/denops.ts b/denops/@denops/denops.ts index 60c18407..648e56fe 100644 --- a/denops/@denops/denops.ts +++ b/denops/@denops/denops.ts @@ -84,6 +84,14 @@ export class Denops { * and the containing module looks like a test module. * * `fn` receive `denops` instance which communicate with real Vim/Neovim. + * + * To use this function, developer must provides the following environment variables: + * + * DENOPS_PATH - A path to `denops.vim` for adding to Vim's `runtimepath` + * DENOPS_TEST_VIM - An executable of Vim + * DENOPS_TEST_NVIM - An executable of Neovim + * + * Otherwise tests using this static method will be ignored. */ static test(t: TestDefinition): void; /** @@ -91,6 +99,14 @@ export class Denops { * and the containing module looks like a test module. * * `fn` receive `denops` instance which communicate with real Vim/Neovim. + * + * To use this function, developer must provides the following environment variables: + * + * DENOPS_PATH - A path to `denops.vim` for adding to Vim's `runtimepath` + * DENOPS_TEST_VIM - An executable of Vim + * DENOPS_TEST_NVIM - An executable of Neovim + * + * Otherwise tests using this static method will be ignored. */ static test( mode: "vim" | "nvim", diff --git a/denops/@denops/test/tester.ts b/denops/@denops/test/tester.ts index ad4f6204..67fbe61d 100644 --- a/denops/@denops/test/tester.ts +++ b/denops/@denops/test/tester.ts @@ -2,13 +2,24 @@ import { path } from "../deps.ts"; import { Denops } from "../denops.ts"; import { DENOPS_TEST_NVIM, DENOPS_TEST_VIM, run } from "./runner.ts"; -const SCRIPT_PATH = path.fromFileUrl(new URL("cli/bypass.ts", import.meta.url)); -const DENOPS_PATH = path.fromFileUrl(new URL("../../..", import.meta.url)); +const DENOPS_PATH = Deno.env.get("DENOPS_PATH"); async function withDenops( mode: "vim" | "nvim", main: (denops: Denops) => Promise | void, ) { + if (!DENOPS_PATH) { + throw new Error("`DENOPS_PATH` environment variable is not defined"); + } + const denopsPath = path.resolve(DENOPS_PATH); + const scriptPath = path.join( + denopsPath, + "denops", + "@denops", + "test", + "cli", + "bypass.ts", + ); const listener = Deno.listen({ hostname: "127.0.0.1", port: 0, // Automatically select free port @@ -16,7 +27,7 @@ async function withDenops( const proc = run(mode, { commands: [ `set runtimepath^=${DENOPS_PATH}`, - `autocmd User DenopsReady call denops#plugin#register('denops-std-test', '${SCRIPT_PATH}')`, + `autocmd User DenopsReady call denops#plugin#register('denops-std-test', '${scriptPath}')`, "call denops#server#start()", ], env: { @@ -54,7 +65,7 @@ export type TestDefinition = Omit & { export function test(t: TestDefinition): void { Deno.test({ ...t, - ignore: (t.mode === "vim" && !DENOPS_TEST_VIM) || + ignore: !DENOPS_PATH || (t.mode === "vim" && !DENOPS_TEST_VIM) || (t.mode === "nvim" && !DENOPS_TEST_NVIM), fn: async () => { await withDenops(t.mode, t.fn);