From 50f58a0624c92d55201398ae50c85857bf53e744 Mon Sep 17 00:00:00 2001 From: Akin Sowemimo <22454918+akinsho@users.noreply.github.com> Date: Sat, 25 Mar 2023 22:21:44 +0000 Subject: [PATCH] ci(tests): use minimal init.lua for tests --- .github/workflows/test.yaml | 6 ------ .gitignore | 1 + tests/minimal.vim | 3 --- tests/minimal_init.lua | 39 +++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .gitignore delete mode 100644 tests/minimal.vim create mode 100644 tests/minimal_init.lua diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 47a33a2..0281fd8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,12 +21,6 @@ jobs: wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb sudo dpkg -i /tmp/nvim.deb - - name: Fetch dependencies - run: | - git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim - git clone --depth 1 https://github.com/kyazdani42/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons - ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start - - name: Run tests run: | nvim --version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69b142e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.tests/ diff --git a/tests/minimal.vim b/tests/minimal.vim deleted file mode 100644 index 7547e39..0000000 --- a/tests/minimal.vim +++ /dev/null @@ -1,3 +0,0 @@ -set rtp+=. -set rtp+=../plenary.nvim -runtime! plugin/plenary.vim diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua new file mode 100644 index 0000000..d0b6f14 --- /dev/null +++ b/tests/minimal_init.lua @@ -0,0 +1,39 @@ +local M = {} + +function M.root(root) + local f = debug.getinfo(1, "S").source:sub(2) + return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "") +end + +---@param plugin string +function M.load(plugin) + local name = plugin:match(".*/(.*)") + local package_root = M.root(".tests/site/pack/deps/start/") + if not vim.loop.fs_stat(package_root .. name) then + print("Installing " .. plugin) + vim.fn.mkdir(package_root, "p") + vim.fn.system({ + "git", + "clone", + "--depth=1", + "https://github.com/" .. plugin .. ".git", + package_root .. "/" .. name, + }) + end +end + +function M.setup() + vim.cmd([[set runtimepath=$VIMRUNTIME]]) + vim.opt.runtimepath:append(M.root()) + vim.opt.packpath = { M.root(".tests/site") } + M.load("nvim-lua/plenary.nvim") + vim.env.XDG_CONFIG_HOME = M.root(".tests/config") + vim.env.XDG_DATA_HOME = M.root(".tests/data") + vim.env.XDG_STATE_HOME = M.root(".tests/state") + vim.env.XDG_CACHE_HOME = M.root(".tests/cache") +end + +vim.o.swapfile = false +_G.__TEST = true + +M.setup()