@@ -3,9 +3,15 @@ local multithreading = require "luacheck.multithreading"
3
3
local helper = require " spec.helper"
4
4
local luacheck_cmd = helper .luacheck_command ()
5
5
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
+
6
12
local function get_output (command , wd , color )
7
13
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
9
15
pending (" uses terminal colors" )
10
16
end
11
17
else
@@ -74,23 +80,23 @@ Total: 0 warnings / 0 errors in 1 file
74
80
Checking spec/samples/good_code.lua OK
75
81
76
82
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" )) )
78
84
end )
79
85
80
86
it (" filters files using --include-files" , function ()
81
87
assert .equal ([[
82
88
Checking spec/samples/bad_code.lua 5 warnings
83
89
84
90
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" )) )
86
92
end )
87
93
88
94
it (" --exclude-files has priority over --include-files" , function ()
89
95
assert .equal ([[
90
96
Checking spec/samples/good_code.lua OK
91
97
92
98
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" )) )
94
100
end )
95
101
96
102
it (" works for incorrect files" , function ()
@@ -922,7 +928,7 @@ spec/samples/python_code.lua:1:6: (E011) expected '=' near '__future__'
922
928
923
929
it (" uses --include-files when expanding folders" , function ()
924
930
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" )) )
926
932
end )
927
933
928
934
describe (" config" , function ()
0 commit comments