Skip to content
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
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
test_script:
- node --version
- npm --version
- npm test
- for %%f in (test\*.js) do node_modules\.bin\lab %%f -v -m 5000 & if errorlevel 1 exit /b 1

build: off

Expand Down
21 changes: 19 additions & 2 deletions test/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,36 @@ var code = require('code');

var child = require('child_process');

var fs = require('fs-extra');
var path = require('path');

var outfile = path.resolve(__dirname, 'output/completion.out');

lab.experiment('flag: --completion', function() {

lab.before(function(done) {
fs.mkdirpSync(path.resolve(__dirname, 'output'));
done();
});

lab.after(function(done) {
fs.remove(path.resolve(__dirname, 'output'));
done();
});

['bash', 'fish', 'powershell', 'zsh'].forEach(function(type) {
lab.test('returns completion script for ' + type, function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type, function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type + ' > ' + outfile, function(err) {
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
code.expect(stdout).to.contain('gulp --completion=' + type);
done(err);
});
});
});

lab.test('shows error message for unknown completion type', function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown > ' + outfile, function() {
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
code.expect(stdout).to.contain('rules for \'unknown\' not found');
done();
});
Expand Down
21 changes: 18 additions & 3 deletions test/flags-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@
var lab = exports.lab = require('lab').script();
var code = require('code');

var fs = require('fs');
var fs = require('fs-extra');
var child = require('child_process');

var path = require('path');
var outfile = path.resolve(__dirname, 'output/flags-help.out');

var output = fs.readFileSync(__dirname + '/expected/flags-help.txt', 'utf8').replace(/(\r\n|\n|\r)\s?/gm,'\n');

lab.experiment('flag: help', function() {

lab.before(function(done) {
fs.mkdirpSync(path.resolve(__dirname, 'output'));
done();
});

lab.after(function(done) {
fs.removeSync(path.resolve(__dirname, 'output'));
done();
});

lab.test('shows help using --help', function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --help --cwd ./test/fixtures', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --help --cwd ./test/fixtures > ' + outfile, function(err) {
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
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) {
child.exec('node ' + __dirname + '/../bin/gulp.js --h --cwd ./test/fixtures > ' + outfile, function(err) {
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
code.expect(stdout.replace(/(\r\n|\n|\r)\s?/gm,'\n')).to.equals(output);
done(err);
});
Expand Down
4 changes: 2 additions & 2 deletions test/flags-tasks-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ var output = require('./expected/flags-tasks-json.json');

lab.experiment('flag: --tasks-json', function() {

var outputString = JSON.stringify(output).replace(/{{path}}/, tildify(path.join(__dirname, 'fixtures/gulpfile.js')));
var outputString = JSON.stringify(output).replace(/{{path}}/, tildify(path.join(__dirname, 'fixtures/gulpfile.js')).replace(/\\/g, '\\\\'));
var expected = JSON.parse(outputString);

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');
stdout = stdout.split('\n');
var parsedJson = JSON.parse(stdout[1]);
code.expect(parsedJson).to.deep.equal(expected);
done(err);
Expand Down