-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
go test -f
needs backslash escaping on Windows (#277)
This adds support for testing on Windows with plenary. I was able to get Busted to run tests but it was a nightmare on Windows and I gave up. The entire setup also involved a lot of moving parts, so I feel PlenaryBusted is still the solution I'd like to keep.
- Loading branch information
1 parent
797b9a2
commit 3d259fd
Showing
10 changed files
with
160 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
local M = {} | ||
|
||
--- Initialize the test environment. | ||
--- Thie file will run once before attempting to run PlenaryBustedDirectory. | ||
function M.init() | ||
vim.cmd([[set runtimepath=$VIMRUNTIME]]) -- reset, otherwise it contains all of $PATH | ||
print("Runtime path: " .. vim.inspect(vim.opt.runtimepath:get())) | ||
-- vim.opt.runtimepath:append(".") -- add project root to runtime path | ||
vim.opt.swapfile = false | ||
local site_dir = ".tests/all/site" | ||
vim.opt.packpath = { site_dir } -- set packpath to the site directory | ||
|
||
-- Clone down plugins, add to runtimepath | ||
local plugins = { | ||
["plenary.nvim"] = { url = "https://github.com/nvim-lua/plenary.nvim" }, | ||
["nvim-nio"] = { url = "https://github.com/nvim-neotest/nvim-nio" }, | ||
["nvim-treesitter"] = { | ||
url = "https://github.com/nvim-treesitter/nvim-treesitter", | ||
}, | ||
neotest = { url = "https://github.com/nvim-neotest/neotest" }, | ||
} | ||
for plugin, data in pairs(plugins) do | ||
local plugin_path = site_dir .. "/pack/deps/start/" .. plugin | ||
if vim.fn.isdirectory(plugin_path) ~= 1 then | ||
os.execute("git clone " .. data.url .. " " .. plugin_path) | ||
else | ||
print("Plugin " .. plugin .. " already downloaded") | ||
end | ||
print("Adding to runtimepath: " .. plugin_path) | ||
vim.opt.runtimepath:append(plugin_path) | ||
end | ||
|
||
print("Runtime path: " .. vim.inspect(vim.opt.runtimepath:get())) | ||
print("Package path: " .. package.path) | ||
|
||
-- Check availability | ||
require("plenary") | ||
require("neotest") | ||
require("nvim-treesitter") | ||
|
||
-- Install go parser, if not already installed | ||
require("nvim-treesitter.configs").setup({ | ||
ensure_installed = { "go" }, | ||
auto_install = true, | ||
sync_install = true, | ||
}) | ||
|
||
-- Check if PlenaryBustedDirectory command is available | ||
vim.cmd([[runtime plugin/plenary.vim]]) | ||
if vim.fn.exists(":PlenaryBustedDirectory") == 0 then | ||
vim.notify( | ||
"minimal_init.lua: Failed to find PlenaryBustedDirectory command. Aborting!", | ||
vim.log.levels.ERROR | ||
) | ||
vim.cmd("q!") | ||
end | ||
end | ||
|
||
M.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,10 @@ | ||
local M = {} | ||
|
||
--- Initialize before running each test. | ||
function M.init() | ||
vim.cmd([[set runtimepath=$VIMRUNTIME]]) | ||
vim.opt.runtimepath:append(".") | ||
vim.cmd([[set runtimepath=$VIMRUNTIME]]) -- reset, otherwise it contains all of $PATH | ||
vim.opt.swapfile = false | ||
|
||
vim.opt.packpath = { | ||
".tests/all/site", | ||
} | ||
|
||
vim.cmd([[ | ||
packadd plenary.nvim | ||
packadd neotest | ||
packadd nvim-nio | ||
packadd nvim-treesitter | ||
]]) | ||
|
||
require("nvim-treesitter.configs").setup({ | ||
ensure_installed = { "go", "lua" }, -- This will install go and lua parsers | ||
auto_install = true, | ||
sync_install = true, | ||
}) | ||
vim.opt.packpath = { ".tests/all/site" } -- set packpath to the site directory | ||
end | ||
|
||
-- Ensure the required Neovim plugins are installed/cloned | ||
os.execute("tests/install.sh") | ||
|
||
M.init() |
Oops, something went wrong.