forked from angular/webdriver-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (87 loc) · 3.07 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
var path = require('path');
var gulp = require('gulp');
var runSequence = require('run-sequence');
var spawn = require('child_process').spawn;
var runSpawn = function(task, args, done) {
done = done || function() {};
var child = spawn(task, args, {stdio: 'inherit'});
var running = false;
child.on('close', function(code) {
if (!running) {
running = true;
done(code);
}
});
child.on('error', function(err) {
if (!running) {
console.error('gulp encountered a child error');
running = true;
done(err || 1);
}
});
return child;
};
// Build
gulp.task('copy', function() {
return gulp.src(['config.json', 'package.json'])
.pipe(gulp.dest('built/'));
});
var tsGlobs = ['lib/**/*.ts', '*spec/**/*.ts'];
gulp.task('format:enforce', () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
return gulp.src(tsGlobs).pipe(
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
});
gulp.task('format', () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
return gulp.src(tsGlobs, { base: '.' }).pipe(
format.format('file', clangFormat)).pipe(gulp.dest('.'));
});
gulp.task('tsc', function(done) {
runSpawn(process.execPath, ['node_modules/typescript/bin/tsc'], done);
});
gulp.task('prepublish', function(done) {
runSequence('tsc', 'copy', done);
});
gulp.task('default', ['prepublish']);
gulp.task('build', ['prepublish']);
// Unit Test Commands
gulp.task('test:unit', ['format', 'build'], function(done) {
runSpawn(process.execPath, ['node_modules/jasmine/bin/jasmine.js'], done);
});
// e2e test helper commands
var e2e_env = {headless: false, kvm: true};
gulp.task('update', ['build'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'update', '--android',
'--android-accept-licenses'], done)
});
gulp.task('start', ['build', 'shutdown'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'start', '--detach', '--seleniumPort',
'4444', '--android', '--appium-port', '4723',
'--quiet'].concat(e2e_env.headless ||
!e2e_env.kvm ? ['--avds', 'none'] : []), done);
});
gulp.task('shutdown', ['build'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'shutdown'], done);
});
gulp.task('test:e2e:inner', ['build'], function(done) {
var config = e2e_env.headless ? 'headless.json' : e2e_env.kvm ? 'full.json' : 'no_android.json';
runSpawn(process.execPath, ['node_modules/jasmine/bin/jasmine.js', 'JASMINE_CONFIG_PATH=' +
path.join('e2e_spec', 'support', config)], done);
});
gulp.task('test:e2e:no_update', function(done) {
runSequence('start', 'test:e2e:inner', 'shutdown', done);
});
gulp.task('test:e2e', function(done) {
runSequence('update', 'test:e2e:no_update', done);
});
// Final command
gulp.task('test', ['test:unit', 'test:e2e']);
gulp.task('test:no_update', ['test:unit', 'test:e2e:no_update']);
gulp.task('test:e2e:no_kvm', [], function(done) {
e2e_env.kvm = false;
runSequence('test:e2e', done);
});