@@ -5,6 +5,11 @@ if (process.argv[2] == '--verbose')
55else
66 global . logLevel = "info" ;
77
8+ if ( process . argv [ 2 ] == 'init' ) {
9+ require ( './init.js' ) ;
10+ return ;
11+ }
12+
813var Log = require ( '../lib/logger' ) ,
914 logger = new Log ( global . logLevel ) ,
1015 BrowserStack = require ( 'browserstack' ) ,
@@ -30,6 +35,7 @@ function terminateAllWorkers(callback) {
3035 if ( worker ) {
3136 logger . debug ( '[%s] Terminated' , worker . string ) ;
3237 clearTimeout ( worker . activityTimeout ) ;
38+ clearTimeout ( worker . testActivityTimeout ) ;
3339 delete workers [ key ] ;
3440 delete workerKeys [ worker . id ] ;
3541 }
@@ -215,7 +221,7 @@ var statusPoller = {
215221 }
216222 } , activityTimeout * 1000 ) ;
217223
218- setTimeout ( function ( ) {
224+ worker . testActivityTimeout = setTimeout ( function ( ) {
219225 if ( worker . acknowledged ) {
220226 var subject = "Tests timed out on: " + worker . string ;
221227 var content = "Worker details:\n" + JSON . stringify ( worker . config , null , 4 ) ;
@@ -275,21 +281,16 @@ function runTests() {
275281}
276282
277283try {
278- if ( process . argv [ 2 ] == 'init' ) {
279- require ( './init.js' ) ;
280- } else {
281- var client = BrowserStack . createClient ( {
282- username : config . username ,
283- password : config . key
284- } ) ;
285- runTests ( ) ;
286- var pid_file = process . cwd ( ) + '/browserstack-run.pid' ;
287- fs . writeFileSync ( pid_file , process . pid , 'utf-8' )
288- process . on ( 'SIGINT' , function ( ) { cleanUpAndExit ( 'SIGINT' , 1 ) } ) ;
289- process . on ( 'SIGTERM' , function ( ) { cleanUpAndExit ( 'SIGTERM' , config . status ) } ) ;
290- }
284+ var client = BrowserStack . createClient ( {
285+ username : config . username ,
286+ password : config . key
287+ } ) ;
288+ runTests ( ) ;
289+ var pid_file = process . cwd ( ) + '/browserstack-run.pid' ;
290+ fs . writeFileSync ( pid_file , process . pid , 'utf-8' )
291+ process . on ( 'SIGINT' , function ( ) { cleanUpAndExit ( 'SIGINT' , 1 ) } ) ;
292+ process . on ( 'SIGTERM' , function ( ) { cleanUpAndExit ( 'SIGTERM' , config . status ) } ) ;
291293} catch ( e ) {
292294 console . log ( e ) ;
293295 console . log ( 'Invalid command.' ) ;
294296}
295-
0 commit comments