1 | var os = require('os');
|
2 | var fs = require('fs');
|
3 | var path = require('path');
|
4 | var argv = require('optimist').argv;
|
5 | var mkdirp = require('mkdirp');
|
6 | var child_process = require('child_process');
|
7 | var _ = require('lodash');
|
8 | var wdioConfig = require('./wdio.conf');
|
9 |
|
10 | function pathExists(path) {
|
11 | try {
|
12 | fs.statSync(path);
|
13 | }
|
14 | catch (err) {
|
15 | if (err.code == 'ENOENT') {
|
16 | return false;
|
17 | }
|
18 | }
|
19 | return true;
|
20 | }
|
21 |
|
22 | function findEgisUi() {
|
23 | var egisUiPath = path.normalize('../EgisUI/build/');
|
24 |
|
25 | if (!pathExists(egisUiPath)) {
|
26 | egisUiPath = './node_modules/@egis/egis-ui/build'
|
27 | }
|
28 | return egisUiPath;
|
29 | }
|
30 |
|
31 | var EGISUI = findEgisUi();
|
32 |
|
33 | module.exports = {
|
34 |
|
35 | EGISUI: EGISUI,
|
36 |
|
37 | unzip: function (path, to)
|
38 | {
|
39 |
|
40 | mkdirp(to);
|
41 | this.sh("unzip -o " + path + " -d " + to);
|
42 | },
|
43 |
|
44 | sh: function (cmd)
|
45 | {
|
46 | return child_process.execSync(cmd).toString('utf8').trim()
|
47 | },
|
48 |
|
49 | exists: function (path)
|
50 | {
|
51 | return pathExists(path);
|
52 | },
|
53 | dateFormat: function(date, fstr, utc) {
|
54 | utc = utc ? 'getUTC' : 'get';
|
55 | return fstr.replace (/%[YmdHMS]/g, function (m) {
|
56 | switch (m) {
|
57 | case '%Y': return date[utc + 'FullYear'] ();
|
58 | case '%m': m = 1 + date[utc + 'Month'] (); break;
|
59 | case '%d': m = date[utc + 'Date'] (); break;
|
60 | case '%H': m = date[utc + 'Hours'] (); break;
|
61 | case '%M': m = date[utc + 'Minutes'] (); break;
|
62 | case '%S': m = date[utc + 'Seconds'] (); break;
|
63 | default: return m.slice (1);
|
64 | }
|
65 |
|
66 | return ('0' + m).slice (-2);
|
67 | });
|
68 | },
|
69 | defaultKarma: function (config)
|
70 | {
|
71 | var hostname = argv.host || process.env['IP'] || this.ip();
|
72 |
|
73 | var launchersBase = 'TestingBot';
|
74 | var customLaunchers = {
|
75 | 'REMOTE-IE10': {
|
76 | base: launchersBase,
|
77 | browserName: 'internet explorer',
|
78 | platform: 'WIN8',
|
79 | version: '10'
|
80 | },
|
81 | 'REMOTE-IE11': {
|
82 | base: launchersBase,
|
83 | browserName: 'internet explorer',
|
84 | platform: 'WIN10',
|
85 | version: '11'
|
86 | },
|
87 | 'REMOTE-MSEdge': {
|
88 | base: launchersBase,
|
89 | browserName: 'microsoftedge',
|
90 | platform: 'WIN10'
|
91 | },
|
92 | 'REMOTE-FF': {
|
93 | base: launchersBase,
|
94 | browserName: 'firefox',
|
95 | platform: 'WIN10'
|
96 | },
|
97 | 'REMOTE-Safari': {
|
98 | base: launchersBase,
|
99 | browserName: 'safari',
|
100 | platform: 'CAPITAN'
|
101 | },
|
102 | 'REMOTE-Chrome': {
|
103 | base: launchersBase,
|
104 | browserName: 'chrome',
|
105 | platform: 'CAPITAN'
|
106 | }
|
107 | };
|
108 |
|
109 | var browsers = Object.keys(customLaunchers);
|
110 |
|
111 | var projectName = argv.projectName;
|
112 | var testingBotBuildName = process.env.CIRCLE_BUILD_NUM;
|
113 | if (testingBotBuildName) testingBotBuildName = '' + projectName + '/' + testingBotBuildName;
|
114 |
|
115 | var group_filename = function(base_fn, ext) {
|
116 | return _.compact([base_fn, argv.group]).join('-') + '.' + ext;
|
117 | };
|
118 | config.set({
|
119 | junitReporter: {
|
120 | outputDir: 'test-output/junit/'
|
121 |
|
122 |
|
123 | },
|
124 | hostname: hostname.split(' ').join(''),
|
125 | basePath: '',
|
126 | frameworks: ['jasmine-jquery', 'jasmine', 'fixture'],
|
127 | exclude: [],
|
128 | preprocessors: {
|
129 | '**/*.js': ['sourcemap'],
|
130 | '**/*.json' : ['json_fixtures']
|
131 | },
|
132 | customLaunchers: customLaunchers,
|
133 | jsonFixturesPreprocessor: {
|
134 | variableName: '__json__'
|
135 | },
|
136 | reporters: ['progress', 'html', 'junit', 'verbose'],
|
137 | testingbot: {
|
138 | testName: (projectName || '') + ' Karma',
|
139 | recordVideo: true,
|
140 | recordScreenshots: true,
|
141 | connectOptions: {
|
142 | verbose: false,
|
143 | 'se-port': 4445,
|
144 | logfile: 'test-output/' + group_filename('testingbot_tunnel', 'log')
|
145 | },
|
146 | build: testingBotBuildName
|
147 | },
|
148 | browsers: browsers,
|
149 | browserDisconnectTimeout: 10*1000,
|
150 | browserDisconnectTolerance: 1,
|
151 | browserNoActivityTimeout: 4*60*1000,
|
152 | captureTimeout: 2*60*1000,
|
153 | htmlReporter: {
|
154 | outputFile: 'test-output/' + group_filename('unit', 'html')
|
155 | },
|
156 | colors: true,
|
157 | logLevel: config.LOG_INFO,
|
158 | autoWatch: true,
|
159 | singleRun: false,
|
160 | hostname: config.hostname.split(' ').join('')
|
161 | });
|
162 | },
|
163 |
|
164 | ip: function ()
|
165 | {
|
166 | var ifaces = os.networkInterfaces();
|
167 | var ip;
|
168 | Object.keys(ifaces).forEach(function (ifname)
|
169 | {
|
170 | ifaces[ifname].forEach(function (iface)
|
171 | {
|
172 |
|
173 | if ('IPv4' !== iface.family || iface.internal !== false || iface.address.startsWith('172'))
|
174 | {
|
175 |
|
176 | return;
|
177 | }
|
178 | ip = iface.address;
|
179 | });
|
180 |
|
181 | });
|
182 | return ip;
|
183 | },
|
184 | defaultWdioConfig: wdioConfig
|
185 | }; |
\ | No newline at end of file |