|
1 | 1 | 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 |
3 | 23 | 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] |
13 | 25 | end |
14 | 26 | end |
0 commit comments