Skip to content

Commit 5ab5d7c

Browse files
committed
Updated batch files for tests.
Tests use folder "temp" instead of "local".
1 parent 128804a commit 5ab5d7c

File tree

8 files changed

+145
-47
lines changed

8 files changed

+145
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/local/
12
/temp/
23

34
/tests/quickTest.lua

tests/runExamples.cmd

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
@ECHO OFF
2-
CD /D "%~dp0.."
2+
REM $ runExamples.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
34

45
SETLOCAL EnableDelayedExpansion
5-
SET _fails=0
66

7-
ECHO Running examples.
7+
REM Prepare Lua command.
8+
SET _lua=%1
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
17+
CD /D "%~dp0.."
18+
19+
20+
21+
ECHO Running examples...
22+
SET _fails=0
823

924
FOR /R examples %%G IN (*.lua2p) DO (
1025
ECHO. & ECHO Processing example '%%~nxG'...
11-
lua ./preprocess-cl.lua "%%G" --debug --silent
12-
IF !ERRORLEVEL! EQU 0 ( lua -e"io.stdout:setvbuf'no'" -e"io.stderr:setvbuf'no'" "%%~dpnG.lua" ) ELSE ( SET /A "_fails=!_fails!+1" )
26+
%_lua% ./preprocess-cl.lua "%%G" --debug --silent
27+
IF !ERRORLEVEL! EQU 0 ( %_lua% -e"io.stdout:setvbuf'no' io.stderr:setvbuf'no'" "%%~dpnG.lua" ) ELSE ( SET /A "_fails=_fails+1" )
1328
)
14-
1529
ECHO.
16-
IF %_fails% EQU 0 ( ECHO Finished examples successfully. ) ELSE ( ECHO Finished examples with %_fails% failures. )
30+
31+
IF %_fails% EQU 0 (
32+
ECHO Finished examples successfully.
33+
) ELSE (
34+
ECHO Finished examples with %_fails% failures.
35+
EXIT /B 1
36+
)

tests/runQuickTest.cmd

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
@ECHO OFF
2+
REM $ runQuickTest.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
4+
5+
SETLOCAL
6+
7+
REM Prepare Lua command.
8+
SET _lua=%1
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
217
CD /D "%~dp0.."
18+
IF NOT EXIST temp MD temp
19+
320

4-
IF NOT EXIST local MD local
521

6-
lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" tests/quickTest.lua2p
7-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" tests/quickTest.lua2p --backtickstrings
8-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" tests/quickTest.lua2p --linenumbers
9-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" tests/quickTest.lua2p --release
10-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" tests/quickTest.lua2p --loglevel=warning
22+
%_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" tests/quickTest.lua2p || EXIT /B 1
23+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" tests/quickTest.lua2p --backtickstrings || EXIT /B 1
24+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" tests/quickTest.lua2p --linenumbers || EXIT /B 1
25+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" tests/quickTest.lua2p --release || EXIT /B 1
26+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" tests/quickTest.lua2p --loglevel=warning || EXIT /B 1
1127

12-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" --outputpaths tests/quickTest.lua2p local/quickTest.output.lua
13-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" --outputpaths tests/quickTest.lua2p local/quickTest.output.lua --linenumbers
28+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" --outputpaths tests/quickTest.lua2p temp/quickTest.output.lua || EXIT /B 1
29+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --data="Hello, world!" --outputpaths tests/quickTest.lua2p temp/quickTest.output.lua --linenumbers || EXIT /B 1
1430

15-
IF %ERRORLEVEL% EQU 0 lua -e"io.stdout:setvbuf'no'" -e"io.stderr:setvbuf'no'" tests/quickTest.lua
31+
%_lua% -e"io.stdout:setvbuf'no' io.stderr:setvbuf'no'" tests/quickTest.lua || EXIT /B 1

tests/runQuickTestUsingApi.cmd

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
@ECHO OFF
2+
REM $ runQuickTestUsingApi.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
4+
5+
SETLOCAL
6+
7+
REM Prepare Lua command.
8+
SET _lua=%1
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
217
CD /D "%~dp0.."
18+
IF NOT EXIST temp MD temp
19+
320

4-
IF NOT EXIST local MD local
521

6-
lua tests/runQuickTestUsingApi.lua
22+
%_lua% tests/runQuickTestUsingApi.lua || EXIT /B 1
723

8-
IF %ERRORLEVEL% EQU 0 lua -e"io.stdout:setvbuf'no'" -e"io.stderr:setvbuf'no'" tests/quickTest.lua
24+
%_lua% -e"io.stdout:setvbuf'no' io.stderr:setvbuf'no'" tests/quickTest.lua || EXIT /B 1

tests/runQuickTestUsingHandler.cmd

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
@ECHO OFF
2+
REM $ runQuickTestUsingHandler.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
4+
5+
SETLOCAL
6+
7+
REM Prepare Lua command.
8+
SET _lua=%1
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
217
CD /D "%~dp0.."
18+
IF NOT EXIST temp MD temp
19+
320

4-
IF NOT EXIST local MD local
521

6-
lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --handler=tests/quickTestHandler.lua tests/quickTest.lua2p
7-
REM lua ./preprocess-cl.lua --debug --saveinfo=local/info.lua --handler=tests/quickTestHandler.lua --outputpaths tests/quickTest.lua2p local/quickTest.output.lua
22+
%_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --handler=tests/quickTestHandler.lua tests/quickTest.lua2p || EXIT /B 1
23+
REM %_lua% ./preprocess-cl.lua --debug --saveinfo=temp/info.lua --handler=tests/quickTestHandler.lua --outputpaths tests/quickTest.lua2p temp/quickTest.output.lua || EXIT /B 1
824

9-
IF %ERRORLEVEL% EQU 0 lua -e"io.stdout:setvbuf'no'" -e"io.stderr:setvbuf'no'" tests/quickTest.lua
25+
%_lua% -e"io.stdout:setvbuf'no' io.stderr:setvbuf'no'" tests/quickTest.lua || EXIT /B 1

tests/runQuickTestUsingStd.cmd

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
@ECHO OFF
2+
REM $ runQuickTestUsingStd.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
4+
5+
SETLOCAL
6+
7+
REM Prepare Lua command.
8+
SET _lua=%1
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
217
CD /D "%~dp0.."
18+
IF NOT EXIST temp MD temp
19+
IF EXIST temp\stdout.txt DEL temp\stdout.txt
20+
IF EXIST temp\stderr.txt DEL temp\stderr.txt
21+
322

4-
IF NOT EXIST temp MD temp
5-
IF EXIST temp\stdout.txt DEL temp\stdout.txt
6-
IF EXIST temp\stderr.txt DEL temp\stderr.txt
723

8-
lua ./preprocess-cl.lua --debug --data="Hello, world!" - <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt
9-
REM lua ./preprocess-cl.lua --debug --data="Hello, world!" - --backtickstrings <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt
10-
REM lua ./preprocess-cl.lua --debug --data="Hello, world!" - --linenumbers <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt
24+
%_lua% ./preprocess-cl.lua --debug --data="Hello, world!" - <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt || EXIT /B 1
25+
REM %_lua% ./preprocess-cl.lua --debug --data="Hello, world!" - --backtickstrings <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt || EXIT /B 1
26+
REM %_lua% ./preprocess-cl.lua --debug --data="Hello, world!" - --linenumbers <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt || EXIT /B 1
1127

12-
REM lua ./preprocess-cl.lua --debug --data="Hello, world!" --outputpaths - - <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt
13-
REM lua ./preprocess-cl.lua --debug --data="Hello, world!" --outputpaths - - --linenumbers <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt
28+
REM %_lua% ./preprocess-cl.lua --debug --data="Hello, world!" --outputpaths - - <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt || EXIT /B 1
29+
REM %_lua% ./preprocess-cl.lua --debug --data="Hello, world!" --outputpaths - - --linenumbers <tests\quickTest.lua2p 1>temp\stdout.txt 2>temp\stderr.txt || EXIT /B 1

tests/runTestSuite.cmd

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
@ECHO OFF
2-
CD /D "%~dp0.."
2+
REM $ runTestSuite.cmd [luaExePath]
3+
REM Default value for luaExePath is "lua".
34

4-
IF NOT EXIST local MD local
5+
SETLOCAL
56

7+
REM Prepare Lua command.
68
SET _lua=%1
7-
IF [%_lua%]==[] SET _lua=lua
9+
SET _luaExt=%~1
10+
SET _luaExt=%_luaExt:~-4%
11+
IF [%_lua%]==[] ( SET _lua=lua & SET "_luaExt=" )
12+
REM Use CALL if the Lua command is a Batch file, because Windows is annoying.
13+
IF /I "%_luaExt%"==".cmd" SET _lua=CALL %_lua%
14+
IF /I "%_luaExt%"==".bat" SET _lua=CALL %_lua%
15+
16+
REM Prepare folders.
17+
CD /D "%~dp0.."
18+
IF NOT EXIST temp MD temp
19+
20+
821

9-
%_lua% tests/suite.lua
22+
%_lua% tests/suite.lua || EXIT /B 1

tests/suite.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -715,27 +715,27 @@ end)
715715
addLabel("Command line")
716716

717717
doTest("Simple processing of single file", function()
718-
assert(writeFile("local/generatedTest.lua2p", [[
718+
assert(writeFile("temp/generatedTest.lua2p", [[
719719
!outputLua("math.floor(1.5)")
720720
]]))
721-
runCommandRequired(luaExe, [[preprocess-cl.lua local/generatedTest.lua2p]])
721+
runCommandRequired(luaExe, [[preprocess-cl.lua temp/generatedTest.lua2p]])
722722

723-
local luaOut = assert(readFile("local/generatedTest.lua"))
723+
local luaOut = assert(readFile("temp/generatedTest.lua"))
724724
assertCodeOutput(luaOut, [[math.floor(1.5)]])
725725
end)
726726

727727
doTest("Send data", function()
728-
assert(writeFile("local/generatedTest.lua2p", [[
728+
assert(writeFile("temp/generatedTest.lua2p", [[
729729
print(!(dataFromCommandLine))
730730
]]))
731-
runCommandRequired(luaExe, [[preprocess-cl.lua --outputpaths --data="Hello, world!" local/generatedTest.lua2p local/generatedTest.lua]])
731+
runCommandRequired(luaExe, [[preprocess-cl.lua --outputpaths --data="Hello, world!" temp/generatedTest.lua2p temp/generatedTest.lua]])
732732

733-
local luaOut = assert(readFile("local/generatedTest.lua"))
733+
local luaOut = assert(readFile("temp/generatedTest.lua"))
734734
assertCodeOutput(luaOut, [[print("Hello, world!")]])
735735
end)
736736

737737
doTest("Handler + multiple files", function()
738-
assert(writeFile("local/generatedHandler.lua", [[
738+
assert(writeFile("temp/generatedHandler.lua", [[
739739
_G.one = 1
740740
return {
741741
aftermeta = function(path, luaString)
@@ -744,14 +744,14 @@ doTest("Handler + multiple files", function()
744744
end,
745745
}
746746
]]))
747-
assert(writeFile("local/generatedTest1.lua2p", "!!local x = one+2*3\n"))
748-
assert(writeFile("local/generatedTest2.lua2p", "!!local y = one+2^10\n"))
747+
assert(writeFile("temp/generatedTest1.lua2p", "!!local x = one+2*3\n"))
748+
assert(writeFile("temp/generatedTest2.lua2p", "!!local y = one+2^10\n"))
749749

750-
runCommandRequired(luaExe, [[preprocess-cl.lua --handler=local/generatedHandler.lua local/generatedTest1.lua2p local/generatedTest2.lua2p]])
750+
runCommandRequired(luaExe, [[preprocess-cl.lua --handler=temp/generatedHandler.lua temp/generatedTest1.lua2p temp/generatedTest2.lua2p]])
751751

752-
local luaOut = assert(readFile("local/generatedTest1.lua"))
752+
local luaOut = assert(readFile("temp/generatedTest1.lua"))
753753
assertCodeOutput(luaOut, [[print("foo");local x = 7]])
754-
local luaOut = assert(readFile("local/generatedTest2.lua"))
754+
local luaOut = assert(readFile("temp/generatedTest2.lua"))
755755
assertCodeOutput(luaOut, enableInts and [[print("foo");local y = 1025.0]] or [[print("foo");local y = 1025]])
756756
end)
757757

0 commit comments

Comments
 (0)