2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-12-05 06:45:52 +08:00
|
|
|
|
2010-12-05 08:11:57 +08:00
|
|
|
var exec = require('child_process').exec;
|
|
|
|
var join = require('path').join;
|
2010-04-23 05:25:13 +08:00
|
|
|
|
2010-12-05 08:11:57 +08:00
|
|
|
var nodePath = process.argv[0];
|
|
|
|
var script = join(common.fixturesDir, 'print-10-lines.js');
|
2010-04-23 05:25:13 +08:00
|
|
|
|
2010-12-05 08:11:57 +08:00
|
|
|
var cmd = nodePath + ' ' + script + ' | head -2';
|
2010-04-23 05:25:13 +08:00
|
|
|
|
2010-12-05 08:11:57 +08:00
|
|
|
var finished = false;
|
2010-04-23 05:25:13 +08:00
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
exec(cmd, function(err, stdout, stderr) {
|
2010-04-23 05:25:13 +08:00
|
|
|
if (err) throw err;
|
2010-12-05 08:11:57 +08:00
|
|
|
var lines = stdout.split('\n');
|
2010-04-23 05:25:13 +08:00
|
|
|
assert.equal(3, lines.length);
|
|
|
|
finished = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
process.addListener('exit', function() {
|
2010-04-23 05:25:13 +08:00
|
|
|
assert.ok(finished);
|
|
|
|
});
|