diff options
| author | ruki <[email protected]> | 2017-05-22 11:50:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-22 11:50:44 +0800 |
| commit | f87fc2eda76a760a0013273ae733950d83eaa190 (patch) | |
| tree | c5664479a21d8d202c7f88dbf207f0a9cd7fb84a /tests/modules | |
| parent | 8cfccb478c5e72d2a81369295d859c8062bf1000 (diff) | |
modify process test
Diffstat (limited to 'tests/modules')
| -rw-r--r-- | tests/modules/process/test.lua | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua index 69fe0b676..aec56cfc6 100644 --- a/tests/modules/process/test.lua +++ b/tests/modules/process/test.lua @@ -1,51 +1,61 @@ 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) + local pro = process.open("echo -n awd", stdout, stderr) + process.wait(pro, inftimeout) process.close(pro) - assert(io.readfile(stdout)=="awd") + assert(io.readfile(stdout) == "awd") end + -- hack test - local hacked = false - try{ + local ok = try + { function () - process.wait("awd",inftimeout) - hacked = true + process.wait("awd", inftimeout) + return true end } - assert(not hacked) - hacked = (process.close("awd") ~= nil) - assert(not hacked) - try{ + assert(ok == nil) + + assert(process.close("awd") == nil) + + ok = try + { function () - process.waitlist("awd",inftimeout) - hacked = true + process.waitlist("awd", inftimeout) + return true end } - assert(not hacked) - try{ + assert(ok == nil) + + ok = try + { function () - process.waitlist({},inftimeout) - hacked = true + process.waitlist({}, inftimeout) + return true end } - assert(not hacked) - try{ + assert(ok == nil) + + ok = try + { function () - process.waitlist({"awd"},inftimeout) - hacked = true + process.waitlist({"awd"}, inftimeout) + return true end } - assert(not hacked) - try{ + assert(ok == nil) + + ok = try + { function () process.open("thismustnotbeaprogramname") - hacked = true + return true end } - assert(not hacked) + assert(ok == nil) end |
