From 9aeced3ae3e4fc43631208ed6e54ce256ce184aa Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 08:19:06 +0800 Subject: add test for os directory operation --- tests/modules/os/test.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/modules/os/test.lua diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua new file mode 100644 index 000000000..29dbbcc39 --- /dev/null +++ b/tests/modules/os/test.lua @@ -0,0 +1,11 @@ +function main() + os.mkdir("test1") + assert(os.exists("test1")) + os.cp("test1","test2") + assert(os.exists("test2")) + os.rmdir("test1") + assert(not os.exists("test1")) + io.writefile("test2/awd","awd") + os.rmdir("test2") + assert(not os.exists("test2")) +end -- cgit v1.3.1 From 4f67991edadbedab69f36a7a3c73b44ff3f65ba6 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 09:26:31 +0800 Subject: add more test on cp/mv --- tests/modules/os/test.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index 29dbbcc39..ffb81d3cc 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -1,4 +1,5 @@ function main() + -- test cpdir os.mkdir("test1") assert(os.exists("test1")) os.cp("test1","test2") @@ -8,4 +9,23 @@ function main() io.writefile("test2/awd","awd") os.rmdir("test2") assert(not os.exists("test2")) + -- test rename + os.mkdir("test1") + assert(os.exists("test1")) + os.mv("test1","test2") + assert(not os.exists("test1")) + assert(os.exists("test2")) + os.rmdir("test2") + assert(not os.exists("test2")) + -- test cp/mvdir into another dir + os.mkdir("test1") + os.mkdir("test2") + assert(os.exists("test1") and os.exists("test2")) + os.cp("test1","test2") + assert(os.exists("test2/test1")) + os.mv("test1","test2/test1") + assert(not os.exists("test1")) + assert(os.exists("test2/test1/test1")) + os.rmdir("test2") + assert(not os.exists("test2")) end -- cgit v1.3.1 From 93fbbb2131cb92fd6d2c5dc64dea3ea54f6e4d64 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 09:31:30 +0800 Subject: add test for os.setenv & os.mclock --- tests/modules/os/test.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index ffb81d3cc..681a2ec75 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -1,4 +1,6 @@ function main() + -- get mclock + local tm = os.mclock() -- test cpdir os.mkdir("test1") assert(os.exists("test1")) @@ -28,4 +30,9 @@ function main() assert(os.exists("test2/test1/test1")) os.rmdir("test2") assert(not os.exists("test2")) + -- test setenv + os.setenv("__AWD","DWA") + assert(os.getenv("__AWD")=="DWA") + -- assert mclock + assert(os.mclock()>=tm) end -- cgit v1.3.1 From b7fc00223bfc9cca1d990faccaf69548f41d97b4 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 10:10:39 +0800 Subject: add --backtrace to better find error --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 89cf9b7f7..a76647228 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,7 @@ build_script: - ps: Remove-Item -Recurse dos2unix,dos2unix.zip - ps: Move-Item -Force tmp xmake\core\_xmake_main.lua - ps: Copy-Item -Force core\build\xmake.exe $HOME\xmake - - cmd: xmake lua tests\test.lua + - cmd: xmake lua --backtrace tests\test.lua on_success: - luacov -- cgit v1.3.1 From f059625a6723ee410c2cd71957ac4402953afece Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 10:11:16 +0800 Subject: hide appveyor.yml appveyor.yml is an extra file in repo that should be hidden rename to `.appveyor.yml` appveyor also support this filename --- .appveyor.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ appveyor.yml | 44 -------------------------------------------- 2 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 .appveyor.yml delete mode 100644 appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..a76647228 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,44 @@ +version: v2.1.5.{build} +os: + - Visual Studio 2013 + - Visual Studio 2015 + - Visual Studio 2017 + +platform: + - Win32 + - Win64 + +install: + - ps: Invoke-Webrequest 'http://luarocks.github.io/luarocks/releases/luarocks-2.4.2-win32.zip' -OutFile luarocks.zip + - ps: Expand-Archive luarocks.zip + - ps: Copy-Item -Recurse luarocks\luarocks-2.4.2-win32\win32\lua5.1 C:\lua + - cmd: cd luarocks\luarocks-2.4.2-win32 + - cmd: install.bat /Q + - cmd: set PATH=%PATH%;C:\Program Files (x86)\LuaRocks;C:\lua\bin + - cmd: cd ..\.. + - ps: Remove-Item luarocks -Recurse -Force + - ps: Remove-Item luarocks.zip + - cmd: luarocks install luacov + - ps: Copy-Item -Recurse C:\lua\share\lua\5.1 $HOME\xmake\lua + +build_script: + - ps: Invoke-Expression (Get-Content scripts\get.ps1 | Out-String) + - cmd: xmake lua versioninfo + - cmd: if %platform%==Win64 xmake f -a x64 -P core + - cmd: xmake -P core + - cmd: set XMAKE_PROGRAM_DIR=%cd%\xmake + - cmd: core\build\xmake lua versioninfo + - ps: Write-Output "require('luacov.runner').init({['statsfile']='$PWD/luacov.stats.out',['reportfile']='$PWD/luacov.report.out'})".replace('\','/') | Out-File tmp + - ps: Write-Output (Get-Content xmake\core\_xmake_main.lua | Out-String) | Out-File tmp -Append + - ps: Invoke-Webrequest 'https://svwh.dl.sourceforge.net/project/dos2unix/dos2unix/7.3.4/dos2unix-7.3.4-win32.zip' -OutFile dos2unix.zip + - ps: Expand-Archive dos2unix.zip + - cmd: dos2unix\bin\dos2unix tmp + - ps: Remove-Item -Recurse dos2unix,dos2unix.zip + - ps: Move-Item -Force tmp xmake\core\_xmake_main.lua + - ps: Copy-Item -Force core\build\xmake.exe $HOME\xmake + - cmd: xmake lua --backtrace tests\test.lua + +on_success: + - luacov + - pip install codecov + - codecov --file luacov.report.out diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a76647228..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: v2.1.5.{build} -os: - - Visual Studio 2013 - - Visual Studio 2015 - - Visual Studio 2017 - -platform: - - Win32 - - Win64 - -install: - - ps: Invoke-Webrequest 'http://luarocks.github.io/luarocks/releases/luarocks-2.4.2-win32.zip' -OutFile luarocks.zip - - ps: Expand-Archive luarocks.zip - - ps: Copy-Item -Recurse luarocks\luarocks-2.4.2-win32\win32\lua5.1 C:\lua - - cmd: cd luarocks\luarocks-2.4.2-win32 - - cmd: install.bat /Q - - cmd: set PATH=%PATH%;C:\Program Files (x86)\LuaRocks;C:\lua\bin - - cmd: cd ..\.. - - ps: Remove-Item luarocks -Recurse -Force - - ps: Remove-Item luarocks.zip - - cmd: luarocks install luacov - - ps: Copy-Item -Recurse C:\lua\share\lua\5.1 $HOME\xmake\lua - -build_script: - - ps: Invoke-Expression (Get-Content scripts\get.ps1 | Out-String) - - cmd: xmake lua versioninfo - - cmd: if %platform%==Win64 xmake f -a x64 -P core - - cmd: xmake -P core - - cmd: set XMAKE_PROGRAM_DIR=%cd%\xmake - - cmd: core\build\xmake lua versioninfo - - ps: Write-Output "require('luacov.runner').init({['statsfile']='$PWD/luacov.stats.out',['reportfile']='$PWD/luacov.report.out'})".replace('\','/') | Out-File tmp - - ps: Write-Output (Get-Content xmake\core\_xmake_main.lua | Out-String) | Out-File tmp -Append - - ps: Invoke-Webrequest 'https://svwh.dl.sourceforge.net/project/dos2unix/dos2unix/7.3.4/dos2unix-7.3.4-win32.zip' -OutFile dos2unix.zip - - ps: Expand-Archive dos2unix.zip - - cmd: dos2unix\bin\dos2unix tmp - - ps: Remove-Item -Recurse dos2unix,dos2unix.zip - - ps: Move-Item -Force tmp xmake\core\_xmake_main.lua - - ps: Copy-Item -Force core\build\xmake.exe $HOME\xmake - - cmd: xmake lua --backtrace tests\test.lua - -on_success: - - luacov - - pip install codecov - - codecov --file luacov.report.out -- cgit v1.3.1 From ee650cd4514fd73a9d75093f7ba92740060be641 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 10:35:57 +0800 Subject: add --backtrace to test in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 15dd1eb0d..c16518024 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ script: - cat xmake/core/_xmake_main.lua >> tmp - mv tmp xmake/core/_xmake_main.lua - cp core/build/xmake $(which xmake) || sudo cp core/build/xmake $(which xmake) - - make test + - xmake lua --backtrace tests\test.lua after_success: - luacov -- cgit v1.3.1 From 147e73b642ad93e7d42f1ecfaf780bf89637efbd Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 11:14:42 +0800 Subject: add tests for process --- tests/modules/process/test.lua | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/modules/process/test.lua diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua new file mode 100644 index 000000000..69fe0b676 --- /dev/null +++ b/tests/modules/process/test.lua @@ -0,0 +1,51 @@ +function main() + -- single process test + local inftimeout=999 + local stdout=os.tmpfile() + local stderr=os.tmpfile() + for i = 1, 2 do + local pro=process.open("echo -n awd",stdout,stderr) + process.wait(pro,inftimeout) + process.close(pro) + assert(io.readfile(stdout)=="awd") + end + -- hack test + local hacked = false + try{ + function () + process.wait("awd",inftimeout) + hacked = true + end + } + assert(not hacked) + hacked = (process.close("awd") ~= nil) + assert(not hacked) + try{ + function () + process.waitlist("awd",inftimeout) + hacked = true + end + } + assert(not hacked) + try{ + function () + process.waitlist({},inftimeout) + hacked = true + end + } + assert(not hacked) + try{ + function () + process.waitlist({"awd"},inftimeout) + hacked = true + end + } + assert(not hacked) + try{ + function () + process.open("thismustnotbeaprogramname") + hacked = true + end + } + assert(not hacked) +end -- cgit v1.3.1 From e78350a94d63e5c220b22277368a77c374287ff2 Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 11:36:49 +0800 Subject: fix path spliter --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c16518024..984917316 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ script: - cat xmake/core/_xmake_main.lua >> tmp - mv tmp xmake/core/_xmake_main.lua - cp core/build/xmake $(which xmake) || sudo cp core/build/xmake $(which xmake) - - xmake lua --backtrace tests\test.lua + - xmake lua --backtrace tests/test.lua after_success: - luacov -- cgit v1.3.1 From b6724648232ed892301457c05cf5ec4deaefc2ed Mon Sep 17 00:00:00 2001 From: TitanSnow Date: Sun, 21 May 2017 12:26:26 +0800 Subject: add tests for string --- tests/modules/string/test.lua | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/modules/string/test.lua diff --git a/tests/modules/string/test.lua b/tests/modules/string/test.lua new file mode 100644 index 000000000..b2e7a23c7 --- /dev/null +++ b/tests/modules/string/test.lua @@ -0,0 +1,4 @@ +function main() + assert(string.less("awd","dwa")) + assert(not string.less("dwa","awd")) +end -- cgit v1.3.1