@@ -56,16 +56,43 @@ describe('Run all Closure unit tests', function() {
56
56
*/
57
57
var executeTest = function ( testPath ) {
58
58
it ( 'runs ' + testPath + ' with success' , function ( done ) {
59
- browser . navigate ( )
60
- . to ( TEST_SERVER + '/' + testPath )
61
- . then ( function ( ) {
62
- waitForTest ( function ( status ) {
63
- expect ( status ) . toBeSuccess ( ) ;
64
- done ( ) ;
59
+ /**
60
+ * Runs the test routines for a given test path and retries up to a
61
+ * certain number of times on timeout.
62
+ * @param {number } tries The number of times to retry on timeout.
63
+ * @param {function } done The function to run on completion.
64
+ */
65
+ var runRoutine = function ( tries , done ) {
66
+ browser . navigate ( )
67
+ . to ( TEST_SERVER + '/' + testPath )
68
+ . then ( function ( ) {
69
+ waitForTest ( function ( status ) {
70
+ expect ( status ) . toBeSuccess ( ) ;
71
+ done ( ) ;
72
+ } , function ( err ) {
73
+ // If browser test execution times out try up to trial times.
74
+ if ( err . message &&
75
+ err . message . indexOf ( 'ETIMEDOUT' ) != - 1 &&
76
+ tries > 0 ) {
77
+ runRoutine ( tries - 1 , done ) ;
78
+ } else {
79
+ done . fail ( err ) ;
80
+ }
81
+ } ) ;
65
82
} , function ( err ) {
66
- done . fail ( err ) ;
83
+ // If browser test execution times out try up to trial times.
84
+ if ( err . message &&
85
+ err . message . indexOf ( 'ETIMEOUT' ) != - 1 &&
86
+ trial > 0 ) {
87
+ runRoutine ( tries - 1 , done ) ;
88
+ } else {
89
+ done . fail ( err ) ;
90
+ }
67
91
} ) ;
68
- } ) ;
92
+ } ;
93
+ // Run test routine. Set timeout retrial to 2 times, eg. test will try
94
+ // 2 more times before giving up.
95
+ runRoutine ( 2 , done ) ;
69
96
} ) ;
70
97
} ;
71
98
0 commit comments