2009-09-21 00:19:33 +08:00
|
|
|
include("common.js");
|
2009-06-24 19:44:12 +08:00
|
|
|
|
|
|
|
var pwd_called = false;
|
|
|
|
|
|
|
|
function pwd (callback) {
|
|
|
|
var output = "";
|
2009-08-27 04:11:51 +08:00
|
|
|
var child = node.createChildProcess("pwd");
|
|
|
|
child.addListener("output", function (s) {
|
2009-08-25 07:06:49 +08:00
|
|
|
puts("stdout: " + JSON.stringify(s));
|
2009-06-24 19:44:12 +08:00
|
|
|
if (s) output += s;
|
2009-06-28 02:40:43 +08:00
|
|
|
});
|
2009-08-27 04:11:51 +08:00
|
|
|
child.addListener("exit", function (c) {
|
2009-08-25 07:06:49 +08:00
|
|
|
puts("exit: " + c);
|
2009-06-24 19:44:12 +08:00
|
|
|
assertEquals(0, c);
|
|
|
|
callback(output);
|
|
|
|
pwd_called = true;
|
2009-06-28 02:40:43 +08:00
|
|
|
});
|
2009-06-24 19:44:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-27 00:22:00 +08:00
|
|
|
pwd(function (result) {
|
2009-08-27 04:03:19 +08:00
|
|
|
p(result);
|
2009-08-27 00:22:00 +08:00
|
|
|
assertTrue(result.length > 1);
|
|
|
|
assertEquals("\n", result[result.length-1]);
|
|
|
|
});
|
2009-06-24 19:44:12 +08:00
|
|
|
|
2009-08-27 00:51:04 +08:00
|
|
|
process.addListener("exit", function () {
|
2009-06-24 19:44:12 +08:00
|
|
|
assertTrue(pwd_called);
|
2009-08-27 00:51:04 +08:00
|
|
|
});
|