Skip to content

Commit da39da8

Browse files
committed
Got rid of Windows command in CL test.
1 parent 34ab508 commit da39da8

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

tests/suite.lua

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
--==============================================================
22
--=
33
--= Test suite for LuaPreprocess
4-
--= Note: The command line program tests expect the OS to be Windows!
54
--=
65
--==============================================================
76

@@ -72,19 +71,15 @@ local function assertCodeOutput(codeOut, codeExpected, message)
7271
end
7372
end
7473

75-
-- command = createCommand( program, argumentsString )
76-
local function createCommand(program, argsStr)
74+
-- command = createCommand( program, rest )
75+
local function createCommand(program, rest)
7776
return program:find(" ", 1, true)
78-
and '""'..program..'" '..argsStr..'"'
79-
or program..' '..argsStr
77+
and '""'..program..'" '..rest..'"'
78+
or program..' '..rest
8079
end
8180

82-
-- runCommand( command )
83-
-- runCommand( program, argumentsString )
84-
-- runCommandToFail( command )
85-
-- runCommandToFail( program, argumentsString )
86-
local function _runCommand(program, argsStr, expectSuccess)
87-
local cmd = not argsStr and program or createCommand(program, argsStr)
81+
local function _runCommand(program, rest, expectSuccess)
82+
local cmd = createCommand(program, rest)
8883
print("Running command: "..cmd)
8984

9085
if jit or _VERSION >= "Lua 5.2" then
@@ -99,11 +94,18 @@ local function _runCommand(program, argsStr, expectSuccess)
9994
else error("Command succeeded unexpectedly: "..cmd, 2) end
10095
end
10196
end
102-
local function runCommand(program, argsStr)
103-
_runCommand(program, argsStr, true)
97+
local function runCommand(program, rest)
98+
_runCommand(program, rest, true)
10499
end
105-
local function runCommandToFail(program, argsStr)
106-
_runCommand(program, argsStr, false)
100+
local function runCommandToFail(program, rest)
101+
_runCommand(program, rest, false)
102+
end
103+
local function runCommandAndSendData(luaExe, rest, dataStr)
104+
local cmd = createCommand(luaExe, rest)
105+
print("Running command: "..cmd)
106+
local handle = assert(io.popen(cmd, "w"))
107+
handle:write(dataStr)
108+
handle:close()
107109
end
108110

109111
local function requireNewTemp(moduleName)
@@ -793,10 +795,7 @@ doTest("Handler + multiple files", function()
793795
end)
794796

795797
doTest("stdin and stdout", function()
796-
local luaExeMaybeQuoted = luaExe:find(" ", 1, true) and '"'..luaExe..'"' or luaExe
797-
798-
writeFile("temp/generatedTest.lua2p", [[ x = !(1+2) ]])
799-
runCommand([[TYPE temp\generatedTest.lua2p | ]]..luaExeMaybeQuoted..[[ preprocess-cl.lua - >temp\generatedTest.lua]])
798+
runCommandAndSendData(luaExe, [[preprocess-cl.lua - >temp\generatedTest.lua]], [[ x = !(1+2) ]])
800799
assertCodeOutput(readFile"temp/generatedTest.lua", [[x = 3]])
801800
end)
802801

0 commit comments

Comments
 (0)