Skip to content

Commit

Permalink
fix task not ending on merged streams, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jul 1, 2014
1 parent 72b7e1d commit b6956d4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
*.log
.tmp
node_modules
build
*.node
Expand Down
2 changes: 1 addition & 1 deletion lib/runTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function (task, done) {
} else if (r && typeof r.pipe === 'function') {
// wait for stream to end

eos(r, { error: true, readable: false }, function(err){
eos(r, { error: true, readable: false, writable: false }, function(err){
finish(err, 'stream');
});

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
"sequencify": "~0.0.7"
},
"devDependencies": {
"event-stream": "~3.1.5",
"gulp-jshint": "~1.6.3",
"map-stream": "~0.1.0",
"merge-stream": "~0.1.2",
"mocha": "~1.17.0",
"should": "~3.0.1",
"q": "~1.0.0",
"event-stream": "~3.1.0",
"map-stream": "~0.1.0"
"should": "~3.0.1",
"vinyl-fs": "~0.3.4"
},
"scripts": {
"test": "mocha"
Expand Down
47 changes: 47 additions & 0 deletions test/gulpTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

var Orchestrator = require('../');
var Q = require('q');
var vfs = require('vinyl-fs');
var es = require('event-stream');
var ms = require('merge-stream');
var jshint = require('gulp-jshint');
var should = require('should');
require('mocha');

Expand Down Expand Up @@ -114,7 +118,50 @@ describe('orchestrator tasks integration tests', function() {
});
gulp.isRunning.should.equal(true);
});
it('should run all async stream tasks', function(done){
var a, fn, fn2, fn3, fn4;
a = 0;
fn = function(cb) {
return vfs.src('./index.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
};
fn2 = function(cb) {
var stream1 = vfs.src('./index.js')
.pipe(vfs.dest('./test/.tmp'));
var stream2 = vfs.src('./index.js')
.pipe(vfs.dest('./test/.tmp'));
return es.concat(stream1, stream2);
};
fn3 = function(cb) {
var stream1 = vfs.src('./index.js')
.pipe(vfs.dest('./test/.tmp'));
var stream2 = vfs.src('./index.js')
.pipe(vfs.dest('./test/.tmp'));
return ms(stream1, stream2);
};
fn4 = function(cb) {
return vfs.src('./index.js')
.pipe(vfs.dest('./test/.tmp'));
};
gulp.task('test', fn);
gulp.task('test2', fn2);
gulp.task('test3', fn3);
gulp.task('test4', fn4);
gulp.on('task_stop', function(){
++a;
});
gulp.start('test');
gulp.start('test2');
gulp.start('test3');
gulp.start('test4', function () {
gulp.isRunning.should.equal(false);
a.should.equal(4);
done();
});
});
it('should emit task_not_found and throw an error when task is not defined', function(done) {
gulp.reset();
var aErr;
gulp.on('task_not_found', function(err){
should.exist(err);
Expand Down

0 comments on commit b6956d4

Please sign in to comment.