This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcommon.js
More file actions
101 lines (93 loc) · 2.69 KB
/
Copy pathcommon.js
File metadata and controls
101 lines (93 loc) · 2.69 KB
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 q = require('q'),
chalk = require('chalk'),
pathUtils = require('../path-utils'),
exposeTestsApi = require('../tests-api.js'),
publicApi = require('../public-api'),
Suite = require('../suite'),
GeminiError = require('../errors/gemini-error');
exports.common = function() {
this
.opt()
.name('configFile')
.long('config').short('c')
.title('Config file')
.end()
.opt()
.name('rootUrl')
.long('root-url').short('r')
.title('Override root url')
.end()
.opt()
.name('gridUrl')
.long('grid-url').short('g')
.title('Override grid url')
.end()
.opt()
.name('screenshotsDir')
.long('screenshots-dir').short('s')
.title('Override screenshots dir')
.end()
.opt()
.name('debug')
.long('debug')
.flag()
.title('Turn on debugging output to the console')
.end()
.opt()
.name('coverage')
.long('coverage')
.flag()
.title('Turn on CSS coverage report')
.end()
.opt()
.name('grep')
.long('grep')
.title('Execute suits matching the pattern only')
.val(function(value) {
return new RegExp(value, 'i');
})
.end()
.arg()
.name('testFiles')
.title('Paths to files or directories, containing tests')
.arr()
.end();
};
exports.buildSuite = function(testFiles) {
return pathUtils.expandPaths(testFiles)
.then(function(expanded) {
var rootSuite = Suite.create('');
exposeTestsApi(publicApi, rootSuite);
expanded.forEach(require);
return rootSuite;
});
};
exports.handleErrors = function(error) {
if (error instanceof GeminiError) {
return handleGeminiError(error);
} else if (error.status === 13) {
//unknow wd error
return handleUnknownWdError(error);
}
return q.reject(error);
};
function handleGeminiError(error) {
console.error(chalk.red('Error: ') + error.message);
if (error.advice) {
console.error(chalk.green('To fix:'), error.advice);
}
return exports.exitCoa(1);
}
function handleUnknownWdError(error) {
console.log(chalk.red('JSONWire Error:'), error.cause.value.message);
return exports.exitCoa(1);
}
exports.exitCoa = function exitCoa(code) {
return q.resolve({
exitCode: code,
toString: function() {
return '';
}
});
};