Skip to content

Commit bdaced7

Browse files
committed
Fix argument quoting in tests on Windows
1 parent 3b40a04 commit bdaced7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

spec/cli_spec.lua

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ local multithreading = require "luacheck.multithreading"
33
local helper = require "spec.helper"
44
local luacheck_cmd = helper.luacheck_command()
55

6+
local function quote(argument)
7+
-- Do not worry about special characters too much, just quote.
8+
local mark = utils.is_windows and '"' or "'"
9+
return mark .. argument .. mark
10+
end
11+
612
local function get_output(command, wd, color)
713
if color then
8-
if package.config:sub(1, 1) == "\\" and not os.getenv("ANSICON") then
14+
if utils.is_windows and not os.getenv("ANSICON") then
915
pending("uses terminal colors")
1016
end
1117
else
@@ -74,23 +80,23 @@ Total: 0 warnings / 0 errors in 1 file
7480
Checking spec/samples/good_code.lua OK
7581
7682
Total: 0 warnings / 0 errors in 1 file
77-
]], get_output "spec/samples/good_code.lua spec/samples/bad_code.lua --no-config --exclude-files '**/??d_code.lua'")
83+
]], get_output("spec/samples/good_code.lua spec/samples/bad_code.lua --no-config --exclude-files " .. quote("**/??d_code.lua")))
7884
end)
7985

8086
it("filters files using --include-files", function()
8187
assert.equal([[
8288
Checking spec/samples/bad_code.lua 5 warnings
8389
8490
Total: 5 warnings / 0 errors in 1 file
85-
]], get_output "spec/samples/good_code.lua spec/samples/bad_code.lua --no-config --include-files '**/??d_code.lua' -qq")
91+
]], get_output("spec/samples/good_code.lua spec/samples/bad_code.lua --no-config -qq --include-files " .. quote("**/??d_code.lua")))
8692
end)
8793

8894
it("--exclude-files has priority over --include-files", function()
8995
assert.equal([[
9096
Checking spec/samples/good_code.lua OK
9197
9298
Total: 0 warnings / 0 errors in 1 file
93-
]], get_output "spec/samples/good_code.lua spec/samples/bad_code.lua --no-config --include-files '**/*.lua' --exclude-files '**/??d_code.lua'")
99+
]], get_output("spec/samples/good_code.lua spec/samples/bad_code.lua --no-config --include-files " .. quote("**/*.lua") .. " --exclude-files " .. quote("**/??d_code.lua")))
94100
end)
95101

96102
it("works for incorrect files", function()
@@ -922,7 +928,7 @@ spec/samples/python_code.lua:1:6: (E011) expected '=' near '__future__'
922928

923929
it("uses --include-files when expanding folders", function()
924930
assert.matches("^Total: %d+ warnings / %d+ errors in 2 files\n$",
925-
get_output "spec/samples -qqq --no-config --include-files '**/*.rockspec'")
931+
get_output("spec/samples -qqq --no-config --include-files " .. quote("**/*.rockspec")))
926932
end)
927933

928934
describe("config", function()

0 commit comments

Comments
 (0)