Skip to content

Commit

Permalink
feat: test_harness windows support (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
derekthecool committed May 24, 2023
1 parent 1403974 commit f7db41f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lua/plenary/test_harness.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function harness.test_directory(directory, opts)
local args = {
"--headless",
"-c",
string.format('lua require("plenary.busted").run("%s")', p:absolute()),
string.format('lua require("plenary.busted").run("%s")', p:absolute():gsub("\\", "\\\\")),
}

if opts.minimal ~= nil then
Expand Down Expand Up @@ -174,10 +174,21 @@ function harness.test_directory(directory, opts)
end

function harness._find_files_to_run(directory)
local finder = Job:new {
command = "find",
args = { directory, "-type", "f", "-name", "*_spec.lua" },
}
local finder
if vim.fn.has "win32" == 1 or vim.fn.has "win64" == 1 then
-- On windows use powershell Get-ChildItem instead
finder = Job:new {
command = "powershell",
args = { "-Command", [[Get-ChildItem -Recurse -n -Filter "*_spec.lua"]] },
cwd = directory,
}
else
-- everywhere else use find
finder = Job:new {
command = "find",
args = { directory, "-type", "f", "-name", "*_spec.lua" },
}
end

return vim.tbl_map(Path.new, finder:sync())
end
Expand Down

0 comments on commit f7db41f

Please sign in to comment.