11var
22 searchForFile = require ( 'child_process' ) . exec ,
33 execFindFile = require ( 'child_process' ) . exec ,
4+ checkIfAppIsRunning = require ( 'child_process' ) . exec ,
45 fs = require ( 'fs' ) ,
56 pullfile ,
67
78 isTimeToExit = false ,
89
910 processTimeout = 20 * 60 * 1000 , // 20 minutes timeout (empirical constant :))
10- searchInterval = 10000 ;
11+ searchInterval = 10 * 1000 ;
1112
1213searchForFile ( "" , getFile ) ;
1314
@@ -24,11 +25,23 @@ function closeProcessAfter(timeout) {
2425}
2526
2627function tryToGetFile ( ) {
28+ var checkApp = checkIfAppIsRunning ( "adb " + runOnDeviceOrEmulator + " shell \"ps | grep com.tns.android_runtime_testapp\"" , checkIfProcessIsRunning ) ;
2729 pullfile = execFindFile ( "adb " + runOnDeviceOrEmulator + " pull /sdcard/android_unit_test_results.xml" , checkIfFileExists ) ;
2830 pullfile . stdout . pipe ( process . stdout , { end : false } ) ;
2931 pullfile . stderr . pipe ( process . stderr , { end : false } ) ;
3032}
3133
34+ function checkIfProcessIsRunning ( err , stdout , stderr ) {
35+ if ( stdout ) {
36+ console . log ( "com.tns.android_runtime_testapp process is running" )
37+ }
38+ else {
39+ console . log ( 'com.tns.android_runtime_testapp process died!' ) ;
40+ process . exit ( 1 ) ;
41+ }
42+
43+ }
44+
3245function checkIfFileExists ( err , stout , stderr ) {
3346
3447 //if you find file in sdcard exit process
@@ -41,7 +54,7 @@ function checkIfFileExists(err, stout, stderr) {
4154 if ( isTimeToExit ) {
4255 console . log ( err ) ;
4356 console . log ( 'Tests results file not found!' ) ;
44- process . exit ( ) ;
57+ process . exit ( 1 ) ;
4558 }
4659 }
4760}
0 commit comments