Skip to content

Commit 7221503

Browse files
sttkphated
authored andcommitted
Build: Improve AppVeyor build
1 parent 1876ae1 commit 7221503

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install:
2121
test_script:
2222
- node --version
2323
- npm --version
24-
- npm test
24+
- for %%f in (test\*.js) do node_modules\.bin\lab %%f -v -m 5000 & if errorlevel 1 exit /b 1
2525

2626
build: off
2727

test/completion.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,36 @@ var code = require('code');
55

66
var child = require('child_process');
77

8+
var fs = require('fs-extra');
9+
var path = require('path');
10+
11+
var outfile = path.resolve(__dirname, 'output/completion.out');
12+
813
lab.experiment('flag: --completion', function() {
914

15+
lab.before(function(done) {
16+
fs.mkdirpSync(path.resolve(__dirname, 'output'));
17+
done();
18+
});
19+
20+
lab.after(function(done) {
21+
fs.remove(path.resolve(__dirname, 'output'));
22+
done();
23+
});
24+
1025
['bash', 'fish', 'powershell', 'zsh'].forEach(function(type) {
1126
lab.test('returns completion script for ' + type, function(done) {
12-
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type, function(err, stdout) {
27+
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type + ' > ' + outfile, function(err) {
28+
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
1329
code.expect(stdout).to.contain('gulp --completion=' + type);
1430
done(err);
1531
});
1632
});
1733
});
1834

1935
lab.test('shows error message for unknown completion type', function(done) {
20-
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown', function(err, stdout) {
36+
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown > ' + outfile, function() {
37+
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
2138
code.expect(stdout).to.contain('rules for \'unknown\' not found');
2239
done();
2340
});

test/flags-help.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,37 @@
33
var lab = exports.lab = require('lab').script();
44
var code = require('code');
55

6-
var fs = require('fs');
6+
var fs = require('fs-extra');
77
var child = require('child_process');
88

9+
var path = require('path');
10+
var outfile = path.resolve(__dirname, 'output/flags-help.out');
11+
912
var output = fs.readFileSync(__dirname + '/expected/flags-help.txt', 'utf8').replace(/(\r\n|\n|\r)\s?/gm,'\n');
1013

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

16+
lab.before(function(done) {
17+
fs.mkdirpSync(path.resolve(__dirname, 'output'));
18+
done();
19+
});
20+
21+
lab.after(function(done) {
22+
fs.removeSync(path.resolve(__dirname, 'output'));
23+
done();
24+
});
25+
1326
lab.test('shows help using --help', function(done) {
14-
child.exec('node ' + __dirname + '/../bin/gulp.js --help --cwd ./test/fixtures', function(err, stdout) {
27+
child.exec('node ' + __dirname + '/../bin/gulp.js --help --cwd ./test/fixtures > ' + outfile, function(err) {
28+
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
1529
code.expect(stdout.replace(/(\r\n|\n|\r)\s?/gm,'\n')).to.equals(output);
1630
done(err);
1731
});
1832
});
1933

2034
lab.test('shows help using short --h', function(done) {
21-
child.exec('node ' + __dirname + '/../bin/gulp.js --h --cwd ./test/fixtures', function(err, stdout) {
35+
child.exec('node ' + __dirname + '/../bin/gulp.js --h --cwd ./test/fixtures > ' + outfile, function(err) {
36+
var stdout = fs.readFileSync(outfile, { encoding: 'utf8' });
2237
code.expect(stdout.replace(/(\r\n|\n|\r)\s?/gm,'\n')).to.equals(output);
2338
done(err);
2439
});

test/flags-tasks-json.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ var output = require('./expected/flags-tasks-json.json');
1111

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

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

1717
lab.test('prints the task list with no args', function(done) {
1818
child.exec('node ' + __dirname + '/../bin/gulp.js --tasks-json --gulpfile "./test/fixtures/gulpfile.js" ', function(err, stdout) {
19-
stdout = stdout.replace(/\\/g, '/').split('\n');
19+
stdout = stdout.split('\n');
2020
var parsedJson = JSON.parse(stdout[1]);
2121
code.expect(parsedJson).to.deep.equal(expected);
2222
done(err);

0 commit comments

Comments
 (0)