2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2009-06-24 19:44:12 +08:00
|
|
|
|
2010-03-18 05:00:17 +08:00
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
2009-06-24 19:44:12 +08:00
|
|
|
var pwd_called = false;
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
function pwd(callback) {
|
|
|
|
var output = '';
|
|
|
|
var child = spawn('pwd');
|
2010-03-18 05:00:17 +08:00
|
|
|
|
|
|
|
child.stdout.setEncoding('utf8');
|
2010-12-06 03:15:30 +08:00
|
|
|
child.stdout.addListener('data', function(s) {
|
|
|
|
console.log('stdout: ' + JSON.stringify(s));
|
2010-03-18 05:00:17 +08:00
|
|
|
output += s;
|
2009-06-28 02:40:43 +08:00
|
|
|
});
|
2010-03-18 05:00:17 +08:00
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
child.addListener('exit', function(c) {
|
|
|
|
console.log('exit: ' + c);
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(0, c);
|
2009-06-24 19:44:12 +08:00
|
|
|
callback(output);
|
|
|
|
pwd_called = true;
|
2009-06-28 02:40:43 +08:00
|
|
|
});
|
2009-06-24 19:44:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
pwd(function(result) {
|
2010-10-12 07:09:02 +08:00
|
|
|
console.dir(result);
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(true, result.length > 1);
|
2010-12-06 03:15:30 +08:00
|
|
|
assert.equal('\n', result[result.length - 1]);
|
2009-08-27 00:22:00 +08:00
|
|
|
});
|
2009-06-24 19:44:12 +08:00
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
process.addListener('exit', function() {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(true, pwd_called);
|
2009-08-27 00:51:04 +08:00
|
|
|
});
|