mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Add state checks to test/saucelabs.js.
This commit is contained in:
@@ -302,9 +302,13 @@ function optionToValue(name, string) {
|
|||||||
*/
|
*/
|
||||||
function onJobStart(error, res, body) {
|
function onJobStart(error, res, body) {
|
||||||
var id = _.result(body, 'js tests', [])[0],
|
var id = _.result(body, 'js tests', [])[0],
|
||||||
statusCode = _.result(res, 'statusCode');
|
statusCode = _.result(res, 'statusCode'),
|
||||||
|
tunnel = this.tunnel;
|
||||||
|
|
||||||
this.starting = false;
|
this.starting = false;
|
||||||
|
if (this.stopping || tunnel.starting || tunnel.stopping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (error || !id || statusCode != 200) {
|
if (error || !id || statusCode != 200) {
|
||||||
if (this.attempts < this.retries) {
|
if (this.attempts < this.retries) {
|
||||||
this.restart();
|
this.restart();
|
||||||
@@ -349,6 +353,9 @@ function onJobStatus(error, res, body) {
|
|||||||
url = data.url;
|
url = data.url;
|
||||||
|
|
||||||
this.checking = false;
|
this.checking = false;
|
||||||
|
if (this.starting || this.stopping || tunnel.starting || tunnel.stopping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.emit('status', jobStatus);
|
this.emit('status', jobStatus);
|
||||||
|
|
||||||
if (!completed && !expired) {
|
if (!completed && !expired) {
|
||||||
@@ -391,7 +398,9 @@ function onJobStatus(error, res, body) {
|
|||||||
*/
|
*/
|
||||||
function onJobStop() {
|
function onJobStop() {
|
||||||
this.stopping = false;
|
this.stopping = false;
|
||||||
this.emit('stop');
|
if (!this.tunnel.starting) {
|
||||||
|
this.emit('stop');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
@@ -449,8 +458,10 @@ Job.prototype.restart = function(callback) {
|
|||||||
* @param {Object} Returns the job instance.
|
* @param {Object} Returns the job instance.
|
||||||
*/
|
*/
|
||||||
Job.prototype.start = function(callback) {
|
Job.prototype.start = function(callback) {
|
||||||
|
var tunnel = this.tunnel;
|
||||||
this.once('start', _.callback(callback, this));
|
this.once('start', _.callback(callback, this));
|
||||||
if (this.starting) {
|
|
||||||
|
if (this.starting || tunnel.starting || tunnel.stopping) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
this.starting = true;
|
this.starting = true;
|
||||||
@@ -470,8 +481,10 @@ Job.prototype.start = function(callback) {
|
|||||||
* @param {Object} Returns the job instance.
|
* @param {Object} Returns the job instance.
|
||||||
*/
|
*/
|
||||||
Job.prototype.status = function(callback) {
|
Job.prototype.status = function(callback) {
|
||||||
|
var tunnel = this.tunnel;
|
||||||
this.once('status', _.callback(callback, this));
|
this.once('status', _.callback(callback, this));
|
||||||
if (this.checking) {
|
|
||||||
|
if (this.checking || this.starting || this.stopping || tunnel.starting || tunnel.stopping) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
this.checking = true;
|
this.checking = true;
|
||||||
@@ -492,7 +505,8 @@ Job.prototype.status = function(callback) {
|
|||||||
*/
|
*/
|
||||||
Job.prototype.stop = function(callback) {
|
Job.prototype.stop = function(callback) {
|
||||||
this.once('stop', _.callback(callback, this));
|
this.once('stop', _.callback(callback, this));
|
||||||
if (this.stopping) {
|
|
||||||
|
if (this.stopping || this.tunnel.starting) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
this.stopping = true;
|
this.stopping = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user