diff options
| author | ruki <[email protected]> | 2017-05-21 21:42:54 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-05-21 21:42:54 +0800 |
| commit | 433c76d7735fc8006ab400850e0e08a4e5bffdc0 (patch) | |
| tree | 6f04d49bf8868e5981e5918813c02c461d75b8e1 | |
| parent | 83f448dc569b70410765dfe6241fabc351feb54f (diff) | |
| parent | b6724648232ed892301457c05cf5ec4deaefc2ed (diff) | |
Merge pull request #110 from TitanSnow/wincov
add tests for C part
| -rw-r--r-- | .appveyor.yml (renamed from appveyor.yml) | 2 | ||||
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | tests/modules/os/test.lua | 38 | ||||
| -rw-r--r-- | tests/modules/process/test.lua | 51 | ||||
| -rw-r--r-- | tests/modules/string/test.lua | 4 |
5 files changed, 95 insertions, 2 deletions
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 diff --git a/.travis.yml b/.travis.yml index 15dd1eb0d..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) - - make test + - xmake lua --backtrace tests/test.lua after_success: - luacov diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua new file mode 100644 index 000000000..681a2ec75 --- /dev/null +++ b/tests/modules/os/test.lua @@ -0,0 +1,38 @@ +function main() + -- get mclock + local tm = os.mclock() + -- test cpdir + 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")) + -- 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")) + -- test setenv + os.setenv("__AWD","DWA") + assert(os.getenv("__AWD")=="DWA") + -- assert mclock + assert(os.mclock()>=tm) +end 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 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 |
