From 1ad233eb83235c84def30636dcc64af456e30e44 Mon Sep 17 00:00:00 2001 From: Adam Figgins Date: Sat, 1 Jun 2024 09:04:34 +0100 Subject: [PATCH] fix(103): Installing nio as deps to fix tests - Moved some test scripts around and left in backup method for test script --- .github/workflows/main.yml | 2 +- Makefile | 3 +- scripts/minimal_init.lua | 30 ----------------- tests/minimal_init.lua | 68 ++++++++++++++++++++++++++++++++++++++ {scripts => tests}/test.sh | 4 +-- 5 files changed, 73 insertions(+), 34 deletions(-) delete mode 100644 scripts/minimal_init.lua create mode 100644 tests/minimal_init.lua rename {scripts => tests}/test.sh (85%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d8dadb..d69f201 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/Makefile b/Makefile index f46a3e4..6a586d5 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 diff --git a/scripts/minimal_init.lua b/scripts/minimal_init.lua deleted file mode 100644 index f8559fa..0000000 --- a/scripts/minimal_init.lua +++ /dev/null @@ -1,30 +0,0 @@ --- 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" - - vim.cmd("set rtp+=" .. neotest_path) - vim.cmd("set rtp+=" .. plenary_path) - vim.cmd("set rtp+=" .. treesitter_path) - vim.cmd("set rtp+=" .. mini_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 diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua new file mode 100644 index 0000000..d97df72 --- /dev/null +++ b/tests/minimal_init.lua @@ -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() diff --git a/scripts/test.sh b/tests/test.sh similarity index 85% rename from scripts/test.sh rename to tests/test.sh index ad4f5c7..81100d4 100755 --- a/scripts/test.sh +++ b/tests/test.sh @@ -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 @@ -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