Skip to content

Commit d8b14e8

Browse files
Romanxphated
authored andcommitted
Update: Add some integration tests
1 parent 6aa90b4 commit d8b14e8

File tree

11 files changed

+185
-2
lines changed

11 files changed

+185
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Command Line Utility for Gulp
5353
<td>Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here.</td>
5454
</tr>
5555
<tr>
56-
<td>--verify</td>
56+
<td>--verify [path (optional)]</td>
5757
<td></td>
5858
<td>Will verify plugins referenced in project's package.json against the plugins blacklist.</td>
5959
</tr>

test/expected/flags-help.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
Usage: gulp [options] tasks
3+
4+
Options:
5+
--help, -h Show this help. [boolean]
6+
--version, -v Print the global and local gulp versions. [boolean]
7+
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string]
8+
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string]
9+
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string]
10+
--verify Will verify plugins referenced in project's package.json against the plugins blacklist.
11+
--tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean]
12+
--tasks-simple Print a plaintext list of tasks for the loaded gulpfile. [boolean]
13+
--tasks-json Print the task dependency tree, in JSON format, for the loaded gulpfile.
14+
--color Will force gulp and gulp plugins to display colors, even when no color support is detected. [boolean]
15+
--no-color Will force gulp and gulp plugins to not display colors, even when color support is detected. [boolean]
16+
--silent, -S Suppress all gulp logging. [boolean]
17+
--continue Continue execution of tasks upon failure. [boolean]
18+
--log-level, -L Set the loglevel. -L for least verbose and -LLLL for most verbose. -LLL is default. [count]
19+

test/fixtures/gulpfile-2.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
var gulp = require('gulp');
3+
4+
function noop() {}
5+
6+
gulp.task('default', noop);

test/fixtures/gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
32
var gulp = require('gulp');
43

54
function noop() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "test-package",
3+
"description": "Test Package for Testing!",
4+
"version": "0.0.1",
5+
"tags": [
6+
],
7+
"files": [
8+
],
9+
"dependencies": {
10+
"gulp-blink": "^0.1.4"
11+
},
12+
"engines": {
13+
"node": ">= 0.9"
14+
},
15+
"licenses": [
16+
{
17+
"type": "MIT",
18+
"url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE"
19+
}
20+
]
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "default-package",
3+
"description": "Test Package for Testing!",
4+
"version": "0.0.1",
5+
"tags": [
6+
],
7+
"files": [
8+
],
9+
"dependencies": {
10+
"gulp-blink": "^0.1.4"
11+
},
12+
"engines": {
13+
"node": ">= 0.9"
14+
},
15+
"licenses": [
16+
{
17+
"type": "MIT",
18+
"url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE"
19+
}
20+
]
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "test-package-2",
3+
"description": "Test Package for Testing!",
4+
"version": "0.0.1",
5+
"tags": [
6+
],
7+
"files": [
8+
],
9+
"dependencies": {
10+
"yargs": "^3.27.0"
11+
},
12+
"engines": {
13+
"node": ">= 0.9"
14+
},
15+
"licenses": [
16+
{
17+
"type": "MIT",
18+
"url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE"
19+
}
20+
]
21+
}

test/flags-gulpfile.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
var lab = exports.lab = require('lab').script();
4+
var code = require('code');
5+
6+
var fs = require('fs');
7+
var child = require('child_process');
8+
9+
lab.experiment('flag: --gulpfile', function() {
10+
11+
lab.test('Manually set path of gulpfile', function(done) {
12+
child.exec('node ' + __dirname + '/../bin/gulp.js --gulpfile "./test/fixtures/gulpfile-2.js"', function(err, stdout) {
13+
stdout = stdout.replace(/\\/g, '/').split('\n');
14+
code.expect(stdout[1]).to.contain('test/fixtures/gulpfile-2.js');
15+
code.expect(stdout[3]).to.contain('Finished \'default\'');
16+
done(err);
17+
});
18+
});
19+
20+
});

test/flags-help.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
var lab = exports.lab = require('lab').script();
4+
var code = require('code');
5+
6+
var fs = require('fs');
7+
var child = require('child_process');
8+
9+
var output = fs.readFileSync(__dirname + '/expected/flags-help.txt', 'utf8').replace(/\r\n/g, '\n');
10+
11+
lab.experiment('flag: help', function() {
12+
13+
lab.test('shows help using --help', function(done) {
14+
child.exec('node ' + __dirname + '/../bin/gulp.js --help', function(err, stdout) {
15+
code.expect(stdout).to.equals(output);
16+
done();
17+
});
18+
});
19+
20+
lab.test('shows help using short --h', function(done) {
21+
child.exec('node ' + __dirname + '/../bin/gulp.js --h', function(err, stdout) {
22+
code.expect(stdout).to.equals(output);
23+
done();
24+
});
25+
});
26+
27+
});

test/flags-require.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var lab = exports.lab = require('lab').script();
4+
var code = require('code');
5+
6+
var fs = require('fs');
7+
var child = require('child_process');
8+
9+
lab.experiment('flag: --require', function() {
10+
lab.test('requires module before running gulpfile');
11+
});

0 commit comments

Comments
 (0)