From f87fc2eda76a760a0013273ae733950d83eaa190 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 22 May 2017 11:50:44 +0800 Subject: modify process test --- tests/modules/process/test.lua | 60 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'tests/modules/process/test.lua') 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 -- cgit v1.3.1