Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive reporting of sync tasks on errors #204

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});