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
87 lines (76 loc) · 2.15 KB
/
Copy pathcommon.js
File metadata and controls
87 lines (76 loc) · 2.15 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
'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');
var DEFAULT_CFG_NAME = '.gemini.yml',
DEFAULT_PLANS_DIR = 'gemini';
exports.testFiles = function() {
this.arg()
.name('testFiles')
.title('Paths to files or directories, containing tests')
.arr()
.def([DEFAULT_PLANS_DIR])
.end();
};
exports.configFile = function() {
this.opt()
.name('configFile')
.long('config').short('c')
.title('Config file')
.def(DEFAULT_CFG_NAME)
.end();
};
exports.configOverrides = function() {
this
.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();
};
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 '';
}
});
};