-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more integration tests, switch to gulp 4 for devDep
- Loading branch information
Showing
18 changed files
with
290 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
Usage: gulp [options] tasks | ||
Options: | ||
--help, -h Show this help. [boolean] | ||
--version, -v Print the global and local gulp versions. [boolean] | ||
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string] | ||
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string] | ||
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string] | ||
--verify Will verify plugins referenced in project's package.json against the plugins blacklist. | ||
--tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean] | ||
--tasks-simple Print a plaintext list of tasks for the loaded gulpfile. [boolean] | ||
--tasks-json Print the task dependency tree, in JSON format, for the loaded gulpfile. | ||
--color Will force gulp and gulp plugins to display colors, even when no color support is detected. [boolean] | ||
--no-color Will force gulp and gulp plugins to not display colors, even when color support is detected. [boolean] | ||
--silent, -S Suppress all gulp logging. [boolean] | ||
--continue Continue execution of tasks upon failure. [boolean] | ||
--log-level, -L Set the loglevel. -L for least verbose and -LLLL for most verbose. -LLL is default. [count] | ||
|
||
Usage: gulp [options] tasks | ||
|
||
Options: | ||
--help, -h Show this help. [boolean] | ||
--version, -v Print the global and local gulp versions. [boolean] | ||
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string] | ||
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string] | ||
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string] | ||
--verify Will verify plugins referenced in project's package.json against the plugins blacklist. | ||
--tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean] | ||
--tasks-simple Print a plaintext list of tasks for the loaded gulpfile. [boolean] | ||
--tasks-json Print the task dependency tree, in JSON format, for the loaded gulpfile. | ||
--color Will force gulp and gulp plugins to display colors, even when no color support is detected. [boolean] | ||
--no-color Will force gulp and gulp plugins to not display colors, even when color support is detected. [boolean] | ||
--silent, -S Suppress all gulp logging. [boolean] | ||
--continue Continue execution of tasks upon failure. [boolean] | ||
--log-level, -L Set the loglevel. -L for least verbose and -LLLL for most verbose. -LLL is default. [count] | ||
|
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 @@ | ||
[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
test1 | ||
test2 | ||
test3 | ||
test4 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
gulp-cli/test | ||
├─┬ test1 | ||
│ └─┬ <series> | ||
│ └── noop | ||
├─┬ test2 | ||
│ └─┬ <series> | ||
│ ├─┬ test1 | ||
│ │ └─┬ <series> | ||
│ │ └── noop | ||
│ └── noop | ||
├─┬ test3 | ||
│ └─┬ <series> | ||
│ └── described | ||
├─┬ test4 | ||
│ └─┬ <series> | ||
│ ├── errorFunction | ||
│ └── anon | ||
└─┬ default | ||
└─┬ <series> | ||
├─┬ test1 | ||
│ └─┬ <series> | ||
│ └── noop | ||
├─┬ test3 | ||
│ └─┬ <series> | ||
│ └── described | ||
└── 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
'use strict'; | ||
var gulp = require('gulp'); | ||
|
||
function noop() {} | ||
|
||
gulp.task('default', noop); | ||
'use strict'; | ||
var gulp = require('gulp'); | ||
|
||
function noop(cb) { | ||
return cb() | ||
} | ||
|
||
gulp.task('default', gulp.series(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,12 @@ | ||
'use strict'; | ||
var gulp = require('gulp'); | ||
|
||
function noop() {} | ||
function described() {} | ||
described.description = 'description'; | ||
|
||
gulp.task('test1', noop); | ||
gulp.task('test2', ['test1'], noop); | ||
gulp.task('test3', described); | ||
|
||
gulp.task('default', ['test1', 'test3'], 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 |
---|---|---|
@@ -1,12 +1,22 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
function noop() {} | ||
function noop(cb) { | ||
return cb() | ||
} | ||
function described() {} | ||
function errorFunction() { | ||
throw new Error('Error!'); | ||
} | ||
function anon(cb) { | ||
return cb() | ||
} | ||
described.description = 'description'; | ||
|
||
gulp.task('test1', noop); | ||
gulp.task('test2', ['test1'], noop); | ||
gulp.task('test3', described); | ||
gulp.task('test1', gulp.series(noop)); | ||
gulp.task('test2', gulp.series('test1', noop)); | ||
gulp.task('test3', gulp.series(described)); | ||
gulp.task('test4', gulp.series(errorFunction, anon)); | ||
|
||
gulp.task('default', ['test1', 'test3'], noop); | ||
gulp.task('default', gulp.series('test1', 'test3', 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
console.log('inside test module'); | ||
exports = function() { | ||
console.log('inside test module function'); | ||
console.log('inside test module'); | ||
exports = function() { | ||
console.log('inside test module function'); | ||
}; |
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,31 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --continue', function() { | ||
|
||
lab.test('continues execution when flag is set', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js test4 --continue --cwd ./test/fixtures', function(err, stdout, stderr) { | ||
code.expect(stdout).to.contain('Starting \'errorFunction\''); | ||
code.expect(stderr).to.contain('\'errorFunction\' errored after'); | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
code.expect(stdout[4]).to.contain('Starting \'anon\''); | ||
code.expect(stdout[5]).to.contain('Finished \'anon\''); | ||
done(); | ||
}); | ||
}); | ||
|
||
lab.test('stops execution when flag is not set', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js test4 --cwd ./test/fixtures', function(err, stdout, stderr) { | ||
code.expect(stdout).to.contain('Starting \'errorFunction\''); | ||
code.expect(stderr).to.contain('\'errorFunction\' errored after'); | ||
code.expect(stdout[4]).to.not.contain('Starting \'anon\''); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --gulpfile', function() { | ||
|
||
lab.test('Manually set path of gulpfile', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --gulpfile "./test/fixtures/gulpfile-2.js"', function(err, stdout) { | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
code.expect(stdout[1]).to.contain('test/fixtures/gulpfile-2.js'); | ||
code.expect(stdout[3]).to.contain('Finished \'default\''); | ||
done(err); | ||
}); | ||
}); | ||
|
||
}); | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --gulpfile', function() { | ||
|
||
lab.test('Manually set path of gulpfile', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --gulpfile "./test/fixtures/gulpfile-2.js"', function(err, stdout) { | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
code.expect(stdout[1]).to.contain('test/fixtures/gulpfile-2.js'); | ||
code.expect(stdout[5]).to.contain('Finished \'default\''); | ||
done(err); | ||
}); | ||
}); | ||
|
||
}); |
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,27 +1,27 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
var output = fs.readFileSync(__dirname + '/expected/flags-help.txt', 'utf8').replace(/\r\n/g, '\n'); | ||
|
||
lab.experiment('flag: help', function() { | ||
|
||
lab.test('shows help using --help', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --help', function(err, stdout) { | ||
code.expect(stdout).to.equals(output); | ||
done(); | ||
}); | ||
}); | ||
|
||
lab.test('shows help using short --h', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --h', function(err, stdout) { | ||
code.expect(stdout).to.equals(output); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
var output = fs.readFileSync(__dirname + '/expected/flags-help.txt', 'utf8').replace(/(\r\n|\n|\r)\s?/gm,'\n'); | ||
|
||
lab.experiment('flag: help', function() { | ||
|
||
lab.test('shows help using --help', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --help --cwd ./test/fixtures', function(err, stdout) { | ||
code.expect(stdout.replace(/(\r\n|\n|\r)\s?/gm,'\n')).to.equals(output); | ||
done(err); | ||
}); | ||
}); | ||
|
||
lab.test('shows help using short --h', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --h --cwd ./test/fixtures', function(err, stdout) { | ||
code.expect(stdout.replace(/(\r\n|\n|\r)\s?/gm,'\n')).to.equals(output); | ||
done(err); | ||
}); | ||
}); | ||
|
||
}); |
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,25 +1,25 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --require', function() { | ||
lab.test('requires module before running gulpfile', function(done) { | ||
child.exec('node ' + __dirname + '\\..\\bin\\gulp.js --require ./test-module.js --cwd ./test/fixtures', function(err, stdout) { | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
code.expect(stdout[0]).to.equal('inside test module'); | ||
code.expect(stdout[1]).to.contain('Requiring external module ./test-module.js'); | ||
done(err); | ||
}); | ||
}); | ||
lab.test('errors if module doesn\'t exist', function(done) { | ||
child.exec('node ' + __dirname + '\\..\\bin\\gulp.js --require ./null-module.js --cwd ./test/fixtures', function(err, stdout, stderr) { | ||
stderr = stderr.replace(/\\/g, '/').split('\n'); | ||
code.expect(stderr[0]).to.contain('Failed to load external module ./null-module.js'); | ||
done(err); | ||
}); | ||
}); | ||
}); | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --require', function() { | ||
lab.test('requires module before running gulpfile', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --require ./test-module.js --cwd ./test/fixtures', function(err, stdout) { | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
code.expect(stdout[0]).to.equal('inside test module'); | ||
code.expect(stdout[1]).to.contain('Requiring external module ./test-module.js'); | ||
done(err); | ||
}); | ||
}); | ||
lab.test('errors if module doesn\'t exist', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --require ./null-module.js --cwd ./test/fixtures', function(err, stdout, stderr) { | ||
stderr = stderr.replace(/\\/g, '/').split('\n'); | ||
code.expect(stderr[0]).to.contain('Failed to load external module ./null-module.js'); | ||
done(err); | ||
}); | ||
}); | ||
}); |
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,18 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var fs = require('fs'); | ||
var child = require('child_process'); | ||
|
||
lab.experiment('flag: --silent', function() { | ||
|
||
lab.test('prints nothing when silent flag is set', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --silent --cwd ./test/fixtures', function(err, stdout) { | ||
code.expect(stdout).to.equal(''); | ||
done(err); | ||
}); | ||
}); | ||
|
||
}); |
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,36 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs-extra'); | ||
var lab = exports.lab = require('lab').script(); | ||
var code = require('code'); | ||
|
||
var child = require('child_process'); | ||
var output = require('./expected/flags-tasks-json.json') | ||
|
||
lab.experiment('flag: --tasks-json', function() { | ||
|
||
lab.test('prints the task list with no args', function(done) { | ||
child.exec('node ' + __dirname + '/../bin/gulp.js --tasks-json --gulpfile "./test/fixtures/gulpfile.js" ', function(err, stdout) { | ||
stdout = stdout.replace(/\\/g, '/').split('\n'); | ||
var parsedJson = JSON.parse(stdout[1]); | ||
code.expect(parsedJson).to.deep.equal(output); | ||
done(err); | ||
}); | ||
}); | ||
|
||
lab.test('writes the task list to file with path', function(done) { | ||
fs.emptyDir(__dirname + '/output/', function(err) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
child.exec('node ' + __dirname + '/../bin/gulp.js --tasks-json "../output/tasks.json" --gulpfile "./test/fixtures/gulpfile.js" ', function(err, stdout) { | ||
var file = fs.readFileSync(__dirname + '/output/tasks.json', 'utf8') | ||
var parsedJson = JSON.parse(file); | ||
code.expect(parsedJson).to.deep.equal(output); | ||
fs.removeSync(__dirname + '/output/') | ||
done(err); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.