summaryrefslogtreecommitdiff
path: root/tests/modules/process/test.lua
blob: aa57a56ccfa8f7ce38aff7f7ed1bd916d9e845de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

local inftimeout = 5000

function test_single_process(t)

    -- single process test
    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)
        t:are_equal(io.readfile(stdout), "awd")
    end
end

function test_hack(t)
    -- hack test
    t:will_raise(function ()
        process.wait("awd", inftimeout)
    end)

    t:require_not(process.close("awd"))

    t:will_raise(function ()
        process.waitlist("awd", inftimeout)
    end)

    t:will_raise(function ()
        process.waitlist({}, inftimeout)
    end)

    t:will_raise(function ()
        process.waitlist({"awd"}, inftimeout)
    end)
end