Skip to content

Commit 9972914

Browse files
committed
add integration testing helpers
closes #4
1 parent 45b00ed commit 9972914

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

lib/mix/tasks/build_host.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule Mix.Tasks.Nvim.BuildHost do
1919

2020
session_opts =
2121
opts
22-
|> Keyword.take([:xdg_home_path, :vim_rc_path])
22+
|> Keyword.take([:xdg_home_path, :xdg_data_path, :vim_rc_path, :nvim_rplugin_manifest])
2323
|> Keyword.put_new(:vim_rc_path, Path.expand("../../init.vim"))
2424

2525
EmbedNVim.start_link([session_name: @nvim_session] ++ session_opts)

lib/nvim/session/embed.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ defmodule NVim.Session.Embed do
33

44
@params_to_env [xdg_home_path: 'XDG_CONFIG_HOME',
55
xdg_data_path: 'XDG_DATA_PATH',
6-
vim_rc_path: 'MYVIMRC']
6+
vim_rc_path: 'MYVIMRC',
7+
nvim_rplugin_manifest: 'NVIM_RPLUGIN_MANIFEST']
78

89
defmodule NullHandler do
910
require Logger

lib/nvim/test/integration.ex

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
defmodule NVim.Test.Integration do
2-
def setup_host(fixtures_path) do
2+
import Mix.Generator, only: [create_file: 3]
3+
4+
def setup_host(fixtures_path, init_rc_content \\ "") do
5+
File.mkdir_p! "#{fixtures_path}/xdg_home"
6+
File.mkdir_p! "#{fixtures_path}/xdg_data"
7+
8+
nvim_config_path = "#{fixtures_path}/xdg_home/nvim"
9+
10+
create_file "#{nvim_config_path}/init.vim", init_rc_content, force: true
11+
System.cmd "mix", ["nvim.install", nvim_config_path]
12+
end
13+
14+
def start_host_session(fixtures_path, session_name \\ IntegrationTest.Session) do
15+
NVim.Session.Embed.start_link(session_name: session_name,
16+
xdg_home_path: "#{fixtures_path}/xdg_home",
17+
xdg_data_path: "#{fixtures_path}/xdg_data",
18+
vim_rc_path: "#{fixtures_path}/xdg_home/nvim/init.vim",
19+
nvim_rplugin_manifest: "#{fixtures_path}/xdg_data/rplugin.vim")
20+
end
21+
22+
def remove_host(fixtures_path) do
323
nvim_config_path = "#{fixtures_path}/xdg_home/nvim"
4-
Mix.Tasks.Nvim.Install.run [nvim_config_path]
5-
6-
File.cd! "#{nvim_config_path}/rplugin/elixir/apps/host", fn->
7-
Mix.Tasks.Nvim.BuildHost.run [
8-
"nvim.build_host",
9-
"--xdg-home-path", "#{fixtures_path}/xdg_home",
10-
"--vim-rc-path", "#{nvim_config_path}/init.vim"
11-
]
12-
end
24+
System.cmd "mix", ["nvim.remove", nvim_config_path]
1325
end
1426
end

0 commit comments

Comments
 (0)