Enable process test for Windows
return require('lib/tap')(function (test)
+ local isWindows = _G.isWindows
+
test("test disable_stdio_inheritance", function (print, p, expect, uv)
uv.disable_stdio_inheritance()
end)
@@ -9,7 +11,7 @@ return require('lib/tap')(function (test)
local handle, pid
handle, pid = uv.spawn(uv.exepath(), {
- args = {"-e", "print 'Hello World'"},
+ args = {"-e", "io.write 'Hello World'"},
stdio = {nil, stdout},
}, expect(function (code, signal)
p("exit", {code=code, signal=signal})
@@ -24,21 +26,30 @@ return require('lib/tap')(function (test)
uv.read_start(stdout, expect(function (err, chunk)
p("stdout", {err=err,chunk=chunk})
assert(not err, err)
+ assert(chunk == "Hello World")
uv.close(stdout)
end))
end)
- if _G.isWindows then return end
+ local cmd, options, expect_status = 'sleep', { args = {1} }, 0
+ if isWindows then
+ cmd = "cmd.exe"
+ options.args = {"/c","pause"}
+ expect_status = 1
+ end
test("spawn and kill by pid", function (print, p, expect, uv)
local handle, pid
- handle, pid = uv.spawn("sleep", {
- args = {1},
- }, expect(function (status, signal)
+ handle, pid = uv.spawn(cmd, options, expect(function (status, signal)
p("exit", handle, {status=status,signal=signal})
- assert(status == 0)
+ assert(status == expect_status)
+ if isWindows then
+ -- just call TerminateProcess, ref uv__kill in libuv/src/win/process.c
+ assert(signal == 0)
+ else
assert(signal == 2)
+ end
uv.close(handle)
end))
p{handle=handle,pid=pid}
@@ -47,11 +58,9 @@ return require('lib/tap')(function (test)
test("spawn and kill by handle", function (print, p, expect, uv)
local handle, pid
- handle, pid = uv.spawn("sleep", {
- args = {1},
- }, expect(function (status, signal)
+ handle, pid = uv.spawn(cmd, options, expect(function (status, signal)
p("exit", handle, {status=status,signal=signal})
- assert(status == 0)
+ assert(status == expect_status)
assert(signal == 15)
uv.close(handle)
end))
@@ -73,7 +82,8 @@ return require('lib/tap')(function (test)
local stdout = uv.new_pipe(false)
local handle, pid
- handle, pid = uv.spawn("cat", {
+ handle, pid = uv.spawn(uv.exepath(), {
+ args = {"-"},
stdio = {stdin, stdout},
}, expect(function (code, signal)
p("exit", {code=code, signal=signal})
@@ -88,10 +98,11 @@ return require('lib/tap')(function (test)
uv.read_start(stdout, expect(function (err, chunk)
p("stdout", {err=err,chunk=chunk})
assert(not err, err)
+ assert(chunk == "Hello World")
uv.close(stdout)
end))
- uv.write(stdin, "Hello World")
+ uv.write(stdin, "io.write('Hello World')")
uv.shutdown(stdin, expect(function ()
uv.close(stdin)
end))
