-
-
Notifications
You must be signed in to change notification settings - Fork 112
Return exit code 1 when incomplete tasks are detected #145
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
Changes from 4 commits
fabfd90
74b167d
e84bfc6
0aade92
b4bbee2
107c1fc
f566b8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"label":"gulp-cli/test/fixtures/gulpfiles","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"test5","nodes":[],"type":"task"},{"label":"test6","nodes":[],"type":"task"},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}]} | ||
{"label":"gulp-cli/test/fixtures/gulpfiles","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"test5","nodes":[],"type":"task"},{"label":"test6","nodes":[],"type":"task"},{"label":"test7","nodes":[],"type":"task"},{"label":"test8","nodes":[],"type":"task"},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ test3 | |
test4 | ||
test5 | ||
test6 | ||
test7 | ||
test8 | ||
default |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,15 @@ function errorFunction() { | |
function anon(cb) { | ||
cb(); | ||
} | ||
|
||
function notCompleting1() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need 2 non-completing tasks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created 2 tasks to also test that the log message is rendered correctly with multiple non-completing tasks. Should I remove the second task? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine. I'm not partial either way. |
||
// Callback is not called | ||
} | ||
|
||
function notCompleting2() { | ||
// Callback is not called | ||
} | ||
|
||
described.description = 'description'; | ||
|
||
gulp.task('test1', gulp.series(noop)); | ||
|
@@ -28,5 +37,7 @@ gulp.task('test3', gulp.series(described)); | |
gulp.task('test4', gulp.series(errorFunction, anon)); | ||
gulp.task('test5', delayed); | ||
gulp.task('test6', noop); | ||
gulp.task('test7', notCompleting1); | ||
gulp.task('test8', notCompleting2); | ||
|
||
gulp.task('default', gulp.series('test1', 'test3', noop)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var expect = require('expect'); | ||
var Semver = require('sver-compat').Semver; | ||
var eraseTime = require('gulp-test-tools').eraseTime; | ||
var runner = require('gulp-test-tools').gulpRunner; | ||
|
||
|
||
function nodeDoesNotNodeSupportExitCode() { | ||
var currentVersion = new Semver(process.versions.node); | ||
var minimalVersion = new Semver('0.11.0'); | ||
return currentVersion.lt(minimalVersion); | ||
} | ||
|
||
describe('sync-task', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use this instead: beforeEach(function(cb) {
if (process.version.slice(5) === 'v0.10') {
this.skip();
}
cb();
}); |
||
it('should return error code 1 if any tasks did not complete', function(done) { | ||
var this_ = this; | ||
|
||
runner({ verbose: false }) | ||
.chdir('test/fixtures/gulpfiles') | ||
.gulp('test6 test7 test8') | ||
.run(function(err) { | ||
if (nodeDoesNotNodeSupportExitCode()) { | ||
// The exit code is set to 1 by setting process.exitCode = 1 which is only supported from nodejs 0.11 on | ||
this_.skip(); | ||
} | ||
expect(err).toNotEqual(null); | ||
expect(err.code).toEqual(1); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should log tasks which did not complete', function(done) { | ||
runner({ verbose: false }) | ||
.chdir('test/fixtures/gulpfiles') | ||
.gulp('test6 test7 test8') | ||
.run(function(err, stdout) { | ||
var lines = stdout.split('\n'); | ||
expect(lines.length).toEqual(8); | ||
expect(eraseTime(lines[5])).toEqual('The following tasks did not complete: test7, test8'); | ||
done(); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't bring in this dep.