summaryrefslogtreecommitdiff
path: root/test/simple/test-pipe-head.js
blob: a77e739e157e720876d436e1381e832c95d6f3d7 (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
var common = require('../common');
var assert = require('assert');

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

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

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

var finished = false;

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


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