Skip to content

Commit

Permalink
Fix: Avoid false positive reporting of sync tasks on errors (fixes #162
Browse files Browse the repository at this point in the history
…) (#204)
  • Loading branch information
stof authored May 20, 2020
1 parent 8570b0c commit 8de7b2a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/versioned/^4.0.0/log/sync-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ function clear(e) {
delete tasks[e.uid];
}

function clearAll() {
tasks = {};
}

function logSyncTask(gulpInst) {

process.once('exit', warn);
gulpInst.on('start', start);
gulpInst.on('stop', clear);
gulpInst.on('error', clear);
// When not running in --continue mode, we need to clear everything on error to avoid
// false positives.
gulpInst.on('error', process.env.UNDERTAKER_SETTLE === 'true' ? clear : clearAll);
}

module.exports = logSyncTask;
18 changes: 18 additions & 0 deletions test/fixtures/gulpfiles/gulpfile-parallel-failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var gulp = require('gulp');

function noop(cb) {
cb();
}

function errorFunction(cb) {
cb(new Error('Error!'));
}

function notCompleting1() {
// Callback is not called
}

gulp.task('default', gulp.parallel(errorFunction, noop));
gulp.task('broken', gulp.parallel(errorFunction, noop, notCompleting1));
27 changes: 27 additions & 0 deletions test/non-completing-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,31 @@ describe('sync-task', function() {
done();
});
});

it('should not log false positive in case of parallel failure', function(done) {
runner({ verbose: false })
.gulp('--gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js')
.run(function(err, stdout) {
expect(stdout).toExclude('The following tasks did not complete:');
done();
});
});

it('should not log false positive in case of parallel failure in continue mode', function(done) {
runner({ verbose: false })
.gulp('--continue --gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js')
.run(function(err, stdout) {
expect(stdout).toExclude('The following tasks did not complete:');
done();
});
});

it('should log non-completing task alongside a failure in continue mode', function(done) {
runner({ verbose: false })
.gulp('--continue --gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js broken')
.run(function(err, stdout) {
expect(stdout).toInclude('The following tasks did not complete: broken, notCompleting1\n');
done();
});
});
});

0 comments on commit 8de7b2a

Please sign in to comment.