From c19f87134edc5ef9c070c9523af9fd15f0bad057 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 3 May 2014 21:41:02 -0700 Subject: [PATCH] Restart tunnel if all jobs have restarted. --- test/saucelabs.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/saucelabs.js b/test/saucelabs.js index 29df925ad..d08b26b89 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -624,6 +624,7 @@ function Tunnel(properties) { }, this); var completed = 0, + restarted = [], success = true, total = all.length, tunnel = this; @@ -641,9 +642,20 @@ function Tunnel(properties) { tunnel.dequeue(); }); + _.invoke(all, 'on', 'restart', function() { + if (!_.contains(restarted, this)) { + restarted.push(this); + } + // restart tunnel if all jobs have restarted + if (_.isEmpty(_.difference(all, restarted))) { + tunnel.restart(); + } + }); + this.on('stop', function() { completed = 0; success = true; + restarted.length = 0; _.invoke(all, 'reset'); });