-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Add flag & config option for running tasks in series (closes #93)
- Loading branch information
1 parent
9df91cc
commit 4f75f10
Showing
17 changed files
with
191 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict'; | ||
|
||
var expect = require('expect'); | ||
var path = require('path'); | ||
|
||
var skipLines = require('gulp-test-tools').skipLines; | ||
var eraseTime = require('gulp-test-tools').eraseTime; | ||
var eraseLapse = require('gulp-test-tools').eraseLapse; | ||
var runner = require('gulp-test-tools').gulpRunner; | ||
|
||
var fixturesDir = path.join(__dirname, 'fixtures/config'); | ||
var runner = require('gulp-test-tools').gulpRunner({ verbose: false }).basedir(fixturesDir); | ||
|
||
describe('config: flags.series', function() { | ||
|
||
it('Should run in series if `flags.series` is true in .gulp.*', | ||
function(done) { | ||
runner | ||
.chdir('flags/series/t') | ||
.gulp('task1 task2') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
|
||
stdout = eraseLapse(eraseTime(skipLines(stdout, 1))); | ||
expect(stdout).toEqual( | ||
'Starting \'task1\'...\n' + | ||
'Finished \'task1\' after ?\n' + | ||
'Starting \'task2\'...\n' + | ||
'Finished \'task2\' after ?\n' + | ||
'' | ||
); | ||
done(); | ||
} | ||
}); | ||
|
||
it('Should run in parallel if `flags.series` is false in .gulp.*', | ||
function(done) { | ||
runner | ||
.chdir('flags/series/f') | ||
.gulp('task1 task2') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
|
||
stdout = eraseLapse(eraseTime(skipLines(stdout, 1))); | ||
expect(stdout).toEqual( | ||
'Starting \'task1\'...\n' + | ||
'Starting \'task2\'...\n' + | ||
'Finished \'task2\' after ?\n' + | ||
'Finished \'task1\' after ?\n' + | ||
'' | ||
); | ||
done(); | ||
} | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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":"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":"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":[]}]}]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ test1 | |
test2 | ||
test3 | ||
test4 | ||
test5 | ||
test6 | ||
default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"flags": { | ||
"series": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
function noop(cb) { | ||
cb(); | ||
} | ||
|
||
function delayed(cb) { | ||
setTimeout(cb, 100); | ||
} | ||
|
||
gulp.task('task1', delayed); | ||
gulp.task('task2', noop); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"flags": { | ||
"series": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
function noop(cb) { | ||
cb(); | ||
} | ||
|
||
function delayed(cb) { | ||
setTimeout(cb, 100); | ||
} | ||
|
||
gulp.task('task1', delayed); | ||
gulp.task('task2', noop); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
var expect = require('expect'); | ||
var runner = require('gulp-test-tools').gulpRunner; | ||
var eraseTime = require('gulp-test-tools').eraseTime; | ||
var eraseLapse = require('gulp-test-tools').eraseLapse; | ||
var skipLines = require('gulp-test-tools').skipLines; | ||
|
||
describe('flag: --series', function() { | ||
|
||
it('runs tasks in series when flag is set', function(done) { | ||
runner({ verbose: false }) | ||
.gulp('test5 test6', '--series', '--cwd ./test/fixtures/gulpfiles') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); | ||
expect(stdout).toEqual( | ||
'Starting \'test5\'...\n' + | ||
'Finished \'test5\' after ?\n' + | ||
'Starting \'test6\'...\n' + | ||
'Finished \'test6\' after ?\n' + | ||
'' | ||
); | ||
done(); | ||
} | ||
}); | ||
|
||
it('runs tasks in parallel when flag is not set', function(done) { | ||
runner({ verbose: false }) | ||
.gulp('test5 test6', '--cwd ./test/fixtures/gulpfiles') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
expect(stdout).toNotMatch('Starting \'anon\''); | ||
stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); | ||
expect(stdout).toEqual( | ||
'Starting \'test5\'...\n' + | ||
'Starting \'test6\'...\n' + | ||
'Finished \'test6\' after ?\n' + | ||
'Finished \'test5\' after ?\n' + | ||
'' | ||
); | ||
done(); | ||
} | ||
}); | ||
|
||
}); |