Skip to content

Commit

Permalink
multi-pipe test
Browse files Browse the repository at this point in the history
  • Loading branch information
polotek committed Jan 13, 2012
1 parent 3d31cf1 commit fefd768
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions tests/test-pipe.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
var assert = require('assert')
, exec = require('child_process').exec
, $p = require(__dirname + '/..')
, exec = require('child_process').exec
, $p = require(__dirname + '/..')
, opts = { out: false }

exec('cat tests/fixtures/3lines.txt | wc -l', function(err, output) {
if(err) { throw err }
assert.equal('3', output.trim())

var opts = { out: false }
$p('cat tests/fixtures/3lines.txt', opts).pipe('wc -l', opts)
.stdout.on('data', function(output) {
assert.equal('3', output.toString().trim())
})
})
if(err) { throw err }
assert.equal('3', output.trim())

$p('cat tests/fixtures/3lines.txt', opts).pipe('wc -l', opts)
.stdout.on('data', function(output) {
assert.equal('3', output.toString().trim())
})
})

exec('cat tests/fixtures/10lines.txt | grep "even" | wc -l'
, function(err, output) {
if(err) { throw err }
assert.equal('5', output.trim())

$p('cat tests/fixtures/10lines.txt', opts)
.pipe('grep "even"', opts)
.pipe('wc -l', opts)
.stdout.on('data', function(output) {
assert.equal('5', output.toString().trim())
})
})

0 comments on commit fefd768

Please sign in to comment.