mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
928 B
45 lines
928 B
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
16 years ago
|
|
||
15 years ago
|
var spawn = require('child_process').spawn;
|
||
|
|
||
16 years ago
|
var pwd_called = false;
|
||
13 years ago
|
var childClosed = false;
|
||
|
var childExited = false;
|
||
16 years ago
|
|
||
14 years ago
|
function pwd(callback) {
|
||
|
var output = '';
|
||
14 years ago
|
var child = common.spawnPwd();
|
||
15 years ago
|
|
||
|
child.stdout.setEncoding('utf8');
|
||
13 years ago
|
child.stdout.on('data', function(s) {
|
||
14 years ago
|
console.log('stdout: ' + JSON.stringify(s));
|
||
15 years ago
|
output += s;
|
||
16 years ago
|
});
|
||
15 years ago
|
|
||
13 years ago
|
child.on('exit', function(c) {
|
||
14 years ago
|
console.log('exit: ' + c);
|
||
15 years ago
|
assert.equal(0, c);
|
||
13 years ago
|
childExited = true;
|
||
|
});
|
||
|
|
||
|
child.on('close', function () {
|
||
16 years ago
|
callback(output);
|
||
|
pwd_called = true;
|
||
13 years ago
|
childClosed = true;
|
||
16 years ago
|
});
|
||
16 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
pwd(function(result) {
|
||
14 years ago
|
console.dir(result);
|
||
15 years ago
|
assert.equal(true, result.length > 1);
|
||
14 years ago
|
assert.equal('\n', result[result.length - 1]);
|
||
16 years ago
|
});
|
||
16 years ago
|
|
||
13 years ago
|
process.on('exit', function() {
|
||
15 years ago
|
assert.equal(true, pwd_called);
|
||
13 years ago
|
assert.equal(true, childExited);
|
||
|
assert.equal(true, childClosed);
|
||
16 years ago
|
});
|