Skip to content

Commit f7db41f

Browse files
authored
feat: test_harness windows support (#476)
1 parent 1403974 commit f7db41f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

lua/plenary/test_harness.lua

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function harness.test_directory(directory, opts)
8383
local args = {
8484
"--headless",
8585
"-c",
86-
string.format('lua require("plenary.busted").run("%s")', p:absolute()),
86+
string.format('lua require("plenary.busted").run("%s")', p:absolute():gsub("\\", "\\\\")),
8787
}
8888

8989
if opts.minimal ~= nil then
@@ -174,10 +174,21 @@ function harness.test_directory(directory, opts)
174174
end
175175

176176
function harness._find_files_to_run(directory)
177-
local finder = Job:new {
178-
command = "find",
179-
args = { directory, "-type", "f", "-name", "*_spec.lua" },
180-
}
177+
local finder
178+
if vim.fn.has "win32" == 1 or vim.fn.has "win64" == 1 then
179+
-- On windows use powershell Get-ChildItem instead
180+
finder = Job:new {
181+
command = "powershell",
182+
args = { "-Command", [[Get-ChildItem -Recurse -n -Filter "*_spec.lua"]] },
183+
cwd = directory,
184+
}
185+
else
186+
-- everywhere else use find
187+
finder = Job:new {
188+
command = "find",
189+
args = { directory, "-type", "f", "-name", "*_spec.lua" },
190+
}
191+
end
181192

182193
return vim.tbl_map(Path.new, finder:sync())
183194
end

0 commit comments

Comments
 (0)