2013-08-16 10:51:51 +00:00
|
|
|
assert = require 'assert'
|
|
|
|
child_process = require 'child_process'
|
|
|
|
path = require 'path'
|
|
|
|
|
|
|
|
describe 'child_process', ->
|
|
|
|
fixtures = path.join __dirname, '..', 'fixtures'
|
|
|
|
|
|
|
|
describe 'child_process.fork', ->
|
|
|
|
it 'should work', (done) ->
|
|
|
|
child = child_process.fork path.join(fixtures, 'module', 'ping.js')
|
|
|
|
child.on 'message', (msg) ->
|
|
|
|
assert.equal msg, 'message'
|
|
|
|
done()
|
|
|
|
child.send 'message'
|
2013-09-05 01:21:39 +00:00
|
|
|
|
|
|
|
it 'should work in forked process', (done) ->
|
|
|
|
child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js')
|
|
|
|
child.on 'message', (msg) ->
|
|
|
|
assert.equal msg, 'message'
|
|
|
|
done()
|
|
|
|
child.send 'message'
|
2013-09-05 01:47:32 +00:00
|
|
|
|
|
|
|
it 'should work in forked process when options.env is specifed', (done) ->
|
|
|
|
child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js'),
|
|
|
|
[],
|
2013-09-05 06:55:22 +00:00
|
|
|
path: process.env['PATH']
|
2013-09-05 01:47:32 +00:00
|
|
|
child.on 'message', (msg) ->
|
|
|
|
assert.equal msg, 'message'
|
|
|
|
done()
|
|
|
|
child.send 'message'
|