diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-08-01 03:24:29 +0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-08-01 03:24:29 +0400 |
commit | 19a62589b20000a64b5faf7992ad4f10801b2fe3 (patch) | |
tree | ea4b282ec0c09bccaa79925699f7bd05e7f09393 /test | |
parent | 4ac633bf2160b49746e279a745ac68e52009857c (diff) |
child_process_uv: add exec, fix simple/test-child-process-exec-cwd
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-child-process-exec-env.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/test/simple/test-child-process-exec-env.js b/test/simple/test-child-process-exec-env.js index 64ec3275503..8ab8de4f462 100644 --- a/test/simple/test-child-process-exec-env.js +++ b/test/simple/test-child-process-exec-env.js @@ -26,27 +26,28 @@ var success_count = 0; var error_count = 0; var response = ''; -var child = exec('/usr/bin/env', {env: {'HELLO': 'WORLD'}}, - function(err, stdout, stderr) { - if (err) { - error_count++; - console.log('error!: ' + err.code); - console.log('stdout: ' + JSON.stringify(stdout)); - console.log('stderr: ' + JSON.stringify(stderr)); - assert.equal(false, err.killed); - } else { - success_count++; - assert.equal(true, stdout != ''); - } - }); +function after(err, stdout, stderr) { + if (err) { + error_count++; + console.log('error!: ' + err.code); + console.log('stdout: ' + JSON.stringify(stdout)); + console.log('stderr: ' + JSON.stringify(stderr)); + assert.equal(false, err.killed); + } else { + success_count++; + assert.equal(true, stdout != ''); + } +} -child.stdout.setEncoding('utf8'); +var child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after); +child.stdout.setEncoding('utf8'); child.stdout.addListener('data', function(chunk) { response += chunk; }); process.addListener('exit', function() { + console.log("response: ", response); assert.equal(1, success_count); assert.equal(0, error_count); assert.ok(response.indexOf('HELLO=WORLD') >= 0); |