diff options
| author | OpportunityLiu <[email protected]> | 2019-06-08 13:34:02 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-06-08 13:34:02 +0800 |
| commit | 1af88102687e493cab40e62b0a2b8b7d42417ae6 (patch) | |
| tree | 272a80b424e68024a9ecda138159864d9659fe5a /tests/modules/process/test.lua | |
| parent | e165a8e43abed4eb2eca64c3b5adefb57cd65600 (diff) | |
improve test lib
Diffstat (limited to 'tests/modules/process/test.lua')
| -rw-r--r-- | tests/modules/process/test.lua | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua index 7b5501994..aa57a56cc 100644 --- a/tests/modules/process/test.lua +++ b/tests/modules/process/test.lua @@ -1,52 +1,36 @@ -function main() + +local inftimeout = 5000 + +function test_single_process(t) -- single process test - local inftimeout = 5000 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") + t:are_equal(io.readfile(stdout), "awd") end +end +function test_hack(t) -- hack test - local ok = try - { - function () - process.wait("awd", inftimeout) - return true - end - } - assert(ok == nil) + t:will_raise(function () + process.wait("awd", inftimeout) + end) - assert(process.close("awd") == nil) + t:require_not(process.close("awd")) - ok = try - { - function () - process.waitlist("awd", inftimeout) - return true - end - } - assert(ok == nil) + t:will_raise(function () + process.waitlist("awd", inftimeout) + end) - ok = try - { - function () - process.waitlist({}, inftimeout) - return true - end - } - assert(ok == nil) + t:will_raise(function () + process.waitlist({}, inftimeout) + end) - ok = try - { - function () - process.waitlist({"awd"}, inftimeout) - return true - end - } - assert(ok == nil) + t:will_raise(function () + process.waitlist({"awd"}, inftimeout) + end) end |
