Skip to content

Commit f5c44ca

Browse files
committed
Server: Remove unnecessary worker check
1 parent 743564e commit f5c44ca

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

lib/server.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -226,42 +226,39 @@ exports.Server = function Server(bsClient, workers) {
226226
config.status += query.failed;
227227
}
228228

229-
// TODO remove this check, must always be true due to `worker` usage above
230-
if (worker) {
231-
bsClient.takeScreenshot(worker.id, function(error, screenshot) {
232-
if (!error && screenshot.url && query && query.failed) {
233-
logger.info('[%s] ' + chalk.yellow('Screenshot:') + ' %s', getTestBrowserInfo(worker), screenshot.url);
234-
}
235-
236-
checkAndTerminateWorker(worker, function(reusedWorker) {
237-
if (!workers[uuid]) {
238-
return;
239-
}
229+
bsClient.takeScreenshot(worker.id, function(error, screenshot) {
230+
if (!error && screenshot.url && query && query.failed) {
231+
logger.info('[%s] ' + chalk.yellow('Screenshot:') + ' %s', getTestBrowserInfo(worker), screenshot.url);
232+
}
240233

241-
if (reusedWorker) {
242-
logger.debug('[%s] Reused', getTestBrowserInfo(worker));
243-
return;
244-
}
234+
checkAndTerminateWorker(worker, function(reusedWorker) {
235+
if (!workers[uuid]) {
236+
return;
237+
}
245238

246-
logger.debug('[%s] Terminated', getTestBrowserInfo(worker));
239+
if (reusedWorker) {
240+
logger.debug('[%s] Reused', getTestBrowserInfo(worker));
241+
return;
242+
}
247243

248-
clearTimeout(workers[uuid].activityTimeout);
249-
clearTimeout(workers[uuid].testActivityTimeout);
250-
delete workers[uuid];
244+
logger.debug('[%s] Terminated', getTestBrowserInfo(worker));
251245

252-
if (utils.objectSize(workers) === 0) {
253-
var color = config.status > 0 ? "red" : "green";
254-
logger.info(chalk[color]("All tests done, failures: %d."), config.status);
246+
clearTimeout(workers[uuid].activityTimeout);
247+
clearTimeout(workers[uuid].testActivityTimeout);
248+
delete workers[uuid];
255249

256-
if (config.status > 0) {
257-
config.status = 1;
258-
}
250+
if (utils.objectSize(workers) === 0) {
251+
var color = config.status > 0 ? "red" : "green";
252+
logger.info(chalk[color]("All tests done, failures: %d."), config.status);
259253

260-
process.kill(process.pid, 'SIGTERM');
254+
if (config.status > 0) {
255+
config.status = 1;
261256
}
262-
});
257+
258+
process.kill(process.pid, 'SIGTERM');
259+
}
263260
});
264-
}
261+
});
265262

266263
response.end();
267264
},

0 commit comments

Comments
 (0)