|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | var lab = exports.lab = require('lab').script();
|
4 |
| -var code = require('code'); |
5 |
| - |
6 |
| -var child = require('child_process'); |
| 4 | +var expect = require('code').expect; |
| 5 | +var runner = require('gulp-test-tools').gulpRunner; |
| 6 | +var eraseTime = require('gulp-test-tools').eraseTime; |
| 7 | +var eraseLapse = require('gulp-test-tools').eraseLapse; |
| 8 | +var skipLines = require('gulp-test-tools').skipLines; |
| 9 | +var headLines = require('gulp-test-tools').headLines; |
7 | 10 |
|
8 | 11 | lab.experiment('flag: --continue', function() {
|
9 | 12 |
|
10 | 13 | lab.test('continues execution when flag is set', function(done) {
|
11 |
| - child.exec('node ' + __dirname + '/../bin/gulp.js test4 --continue --cwd ./test/fixtures/gulpfiles', function(err, stdout, stderr) { |
12 |
| - code.expect(stdout).to.contain('Starting \'errorFunction\''); |
13 |
| - code.expect(stderr).to.contain('\'errorFunction\' errored after'); |
14 |
| - stdout = stdout.replace(/\\/g, '/').split('\n'); |
15 |
| - code.expect(stdout[4]).to.contain('Starting \'anon\''); |
16 |
| - code.expect(stdout[5]).to.contain('Finished \'anon\''); |
| 14 | + runner({ verbose: false }) |
| 15 | + .gulp('test4', '--continue', '--cwd ./test/fixtures/gulpfiles') |
| 16 | + .run(cb); |
| 17 | + |
| 18 | + function cb(err, stdout, stderr) { |
| 19 | + expect(err).to.be.not.null(); |
| 20 | + |
| 21 | + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); |
| 22 | + expect(stdout).to.equal( |
| 23 | + 'Starting \'test4\'...\n' + |
| 24 | + 'Starting \'errorFunction\'...\n' + |
| 25 | + 'Starting \'anon\'...\n' + |
| 26 | + 'Finished \'anon\' after ?\n' + |
| 27 | + '' |
| 28 | + ); |
| 29 | + |
| 30 | + stderr = eraseLapse(eraseTime(headLines(stderr, 2))); |
| 31 | + expect(stderr).to.equal( |
| 32 | + '\'errorFunction\' errored after ?\n' + |
| 33 | + 'Error: Error!' |
| 34 | + ); |
17 | 35 | done();
|
18 |
| - }); |
| 36 | + } |
19 | 37 | });
|
20 | 38 |
|
21 | 39 | lab.test('stops execution when flag is not set', function(done) {
|
22 |
| - child.exec('node ' + __dirname + '/../bin/gulp.js test4 --cwd ./test/fixtures/gulpfiles', function(err, stdout, stderr) { |
23 |
| - code.expect(stdout).to.contain('Starting \'errorFunction\''); |
24 |
| - code.expect(stderr).to.contain('\'errorFunction\' errored after'); |
25 |
| - code.expect(stdout[4]).to.not.contain('Starting \'anon\''); |
| 40 | + runner({ verbose: false }) |
| 41 | + .gulp('test4', '--cwd ./test/fixtures/gulpfiles') |
| 42 | + .run(cb); |
| 43 | + |
| 44 | + function cb(err, stdout, stderr) { |
| 45 | + expect(err).to.be.not.null(); |
| 46 | + |
| 47 | + expect(stdout).to.not.contain('Starting \'anon\''); |
| 48 | + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); |
| 49 | + expect(stdout).to.equal( |
| 50 | + 'Starting \'test4\'...\n' + |
| 51 | + 'Starting \'errorFunction\'...\n' + |
| 52 | + '' |
| 53 | + ); |
| 54 | + |
| 55 | + stderr = eraseLapse(eraseTime(headLines(stderr, 2))); |
| 56 | + expect(stderr).to.equal( |
| 57 | + '\'errorFunction\' errored after ?\n' + |
| 58 | + 'Error: Error!' |
| 59 | + ); |
26 | 60 | done();
|
27 |
| - }); |
| 61 | + } |
28 | 62 | });
|
29 | 63 |
|
30 | 64 | });
|
0 commit comments