summaryrefslogtreecommitdiff
path: root/test/simple/test-pipe-head.js
blob: 3dbef16d9886f22f5525b7ccbba8223eeb6352fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
common = require("../common");
assert = common.assert

exec = require('child_process').exec;
join = require('path').join;

nodePath = process.argv[0];
script = join(common.fixturesDir, 'print-10-lines.js');

cmd = nodePath + ' ' + script + ' | head -2';

finished = false;

exec(cmd, function (err, stdout, stderr) {
  if (err) throw err;
  lines = stdout.split('\n');
  assert.equal(3, lines.length);
  finished = true;
});


process.addListener('exit', function () {
  assert.ok(finished);
});