-
Notifications
You must be signed in to change notification settings - Fork 64
/
index.js
executable file
·162 lines (138 loc) · 4.36 KB
/
index.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env node
/*jslint forin:true sub:true anon:true, sloppy:true, stupid:true nomen:true, node:true continue:true*/
/*
* Copyright (c) 2012, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
//setting appRoot
global.appRoot = __dirname;
//recording currentFolder
global.workingDirectory = process.cwd();
//Array for holding coverage files.
global.coverageMap = [];
//Array for Holding Report Files
global.reportMap = [];
global.pathSep = require("path").sep || '/';
//getting command line args
global.routerMap = {};
global.failedDescriptors = [];
var Arrow = require("./lib/interface/arrow");
var ArrowSetup = require('./lib/util/arrowsetup');
var Help = require('./lib/util/help');
var nopt = require("nopt");
var Properties = require("./lib/util/properties");
var fs = require("fs");
var path = require("path");
var knownOpts = {
"browser": [String, null],
"lib": [String, null],
"shareLibPath": [String, null],
"enableShareLibYUILoader": Boolean,
"page": [String, null],
"driver": [String, null],
"controller": [String, null],
"engine": [String, null],
"engineConfig": [String, null],
"reuseSession": Boolean,
"parallel": [Number, null],
"report": Boolean,
"coverage": Boolean,
"coverageExclude": [String, null],
"reportFolder": [String, null],
"testName": [String, null],
"group": [String, null],
"logLevel": [String, null],
"context": [String, null],
"dimensions": [String, null],
"capabilities": [String, null],
"seleniumHost": [String, null],
"retryCount": [Number, null],
"exitCode": Boolean,
"color": Boolean,
"keepIstanbulCoverageJson": Boolean,
"defaultAppSeed": [String,null],
"artifactsUrl": [String, null]
},
shortHands = {},
//TODO : Investigate and implement shorthands
// , "br" : ["--browser"]
// , "lb" : ["--lib"]
// , "p" : ["--page"]
// , "d" : ["--driver"]
// , "ct" : ["--controller"]
// , "rs" : ["--reuseSession"]
// , "rp" : ["--report"]
// , "t" : ["--testName"]
// , "g" : ["--group"]
// , "ll" : ["--logLevel"]
// , "cx" : ["--context"]
// , "dm" : ["--dimension"]
// , "sh" : ["--seleniumHost"]
//}
argv = nopt(knownOpts, shortHands, process.argv, 2),
arrow,
prop,
config,
arrowSetup;
if (argv.help) {
Help.showHelp();
process.exit(0);
}
if (argv.version) {
console.log("v" + JSON.parse(fs.readFileSync(global.appRoot + "/package.json", "utf-8")).version);
process.exit(0);
}
if (argv.argv.remain.length === 0 && argv.argv.cooked.length === 1) {
console.error("Unknown option : '" + argv.argv.cooked[0] + "'");
process.exit(0);
}
//adding support for --descriptor param
if (argv.argv.remain.length === 0 && argv.descriptor) {
argv.argv.remain.push(argv.descriptor);
delete argv.descriptor;
}
//store start time
global.startTime = Date.now();
//check if user wants to override default config.
if (!argv.config) {
try {
if (fs.lstatSync(path.join(process.cwd(),"config.js")).isFile()) {
argv.config = path.join(process.cwd(),"/config.js");
}
} catch (e) {
//console.log("No Custom Config File.")
}
if (!argv.config) {
try {
if (fs.lstatSync(path.join(process.cwd(), "config/config.js")).isFile()) {
argv.config = path.join(process.cwd(), "/config/config.js");
}
} catch (e) {
//console.log("No Custom Config File.")
}
}
}
//setup config
prop = new Properties(__dirname + "/config/config.js", argv.config, argv);
config = prop.getAll();
//global variables
global.retryCount = config.retryCount;
global.keepIstanbulCoverageJson = config.keepIstanbulCoverageJson;
global.color = config.color;
function startArrow() {
// TODO: arrowSetup move to Arrow
arrowSetup = new ArrowSetup(config, argv);
this.arrow = Arrow;
arrowSetup.setup(function () {
arrow = new Arrow(config, argv);
arrow.run();
});
}
if (config.shareLibPath !== undefined) {
var LibScanner = require('./lib/util/sharelibscanner');
var libScanner = new LibScanner(config);
libScanner.genSeedFile(config.shareLibPath, startArrow);
} else {
startArrow();
}