Skip to content

Commit

Permalink
fix(103): Installing nio as deps to fix tests
Browse files Browse the repository at this point in the history
- Moved some test scripts around and left in backup method for test
  script
  • Loading branch information
Issafalcon committed Jun 1, 2024
1 parent 4cbf726 commit 1ad233e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
timeout-minutes: 2
strategy:
matrix:
neovim_version: ['v0.9.1', 'v0.9.4', 'nightly']
neovim_version: ['v0.9.1', 'v0.9.4', 'v0.10.0', 'nightly']

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all:
# runs all the test files.
test:
nvim --version | head -n 1 && echo ''
./scripts/test.sh
./tests/test.sh

# installs `mini.nvim`, used for both the tests and documentation.
deps:
Expand All @@ -15,6 +15,7 @@ deps:
git clone --depth 1 https://github.com/nvim-neotest/neotest.git deps/neotest
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim.git deps/plenary
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter.git deps/nvim-treesitter
git clone --depth 1 https://github.com/nvim-neotest/nvim-nio deps/nvim-nio

# installs deps before running tests, useful for the CI.
test-ci: deps test
Expand Down
30 changes: 0 additions & 30 deletions scripts/minimal_init.lua

This file was deleted.

68 changes: 68 additions & 0 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- Add current directory to 'runtimepath' to be able to use 'lua' files
vim.cmd([[let &rtp.=','.getcwd()]])

-- When running headless only (i.e. via Makefile command)
if #vim.api.nvim_list_uis() == 0 then
-- Add dependenices to rtp (installed via the Makefile 'deps' command)
local neotest_path = vim.fn.getcwd() .. "/deps/neotest"
local plenary_path = vim.fn.getcwd() .. "/deps/plenary"
local treesitter_path = vim.fn.getcwd() .. "/deps/nvim-treesitter"
local mini_path = vim.fn.getcwd() .. "/deps/mini.doc.nvim"
local nio_path = vim.fn.getcwd() .. "/deps/nvim-nio"

vim.cmd("set rtp+=" .. neotest_path)
vim.cmd("set rtp+=" .. plenary_path)
vim.cmd("set rtp+=" .. treesitter_path)
vim.cmd("set rtp+=" .. mini_path)
vim.cmd("set rtp+=" .. nio_path)

-- Source the plugin dependency files
vim.cmd("runtime plugin/nvim-treesitter.lua")
vim.cmd("runtime plugin/plenary.vim")
vim.cmd("runtime lua/mini/doc.lua")

-- Setup test plugin dependencies
require("nvim-treesitter.configs").setup({
ensure_installed = "c_sharp",
sync_install = true,
highlight = {
enable = false,
},
})
end
-- 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-treesitter/nvim-treesitter")
-- M.load("nvim-lua/plenary.nvim")
-- M.load("Issafalcon/neotest-dotnet")
-- M.load("echasnovski/mini.doc")
-- end
--
-- M.setup()
4 changes: 2 additions & 2 deletions scripts/test.sh → tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
tempfile=".test_output.tmp"
TEST_INIT=scripts/minimal_init.lua
TEST_INIT=tests/minimal_init.lua
TEST_DIR=tests/

if [[ -n $1 ]]; then
Expand All @@ -9,7 +9,7 @@ if [[ -n $1 ]]; then
else
nvim --headless --clean --noplugin -u ${TEST_INIT} \
-c "set rtp?" \
-c "lua vim.cmd([[PlenaryBustedDirectory ${TEST_DIR} { minimal_init = '${TEST_INIT}'}]])" | tee "${tempfile}"
-c "lua vim.cmd([[PlenaryBustedDirectory ${TEST_DIR} { minimal_init = '${TEST_INIT}', sequential = true}]])" | tee "${tempfile}"
fi

# Plenary doesn't emit exit code 1 when tests have errors during setup
Expand Down

0 comments on commit 1ad233e

Please sign in to comment.