From e613198af7d8fb74b47ebc2add43c4d0420d42ea Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 30 May 2014 14:58:08 -0400 Subject: [PATCH] Detect sauce error message in result. --- test/saucelabs.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/test/saucelabs.js b/test/saucelabs.js index 829d91f9a..8dad1e474 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -406,26 +406,29 @@ function onJobStart(error, res, body) { * @param {Object} body The response body JSON object. */ function onJobStatus(error, res, body) { + this.checking = false; + + if (!this.running || this.stopping) { + return; + } var completed = _.result(body, 'completed', false), data = _.first(_.result(body, 'js tests')), + elapsed = (_.now() - this.timestamp) / 1000, jobId = _.result(data, 'job_id', null), jobResult = _.result(data, 'result', null), jobStatus = _.result(data, 'status', ''), jobUrl = _.result(data, 'url', null), - options = this.options, - message = _.result(jobResult, 'message'), - platform = options.platforms[0], - description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]), - elapsed = (_.now() - this.timestamp) / 1000, - errored = !_.isObject(jobResult) || !jobResult.passed || reError.test(message) || reError.test(jobStatus), expired = (elapsed >= queueTimeout && !_.contains(jobStatus, 'in progress')), - failures = _.result(jobResult, 'failed'), - label = options.name + ':', - tunnel = this.tunnel; + options = this.options, + platform = options.platforms[0]; - this.checking = false; - if (!this.running || this.stopping) { - return; + if (_.isObject(jobResult)) { + var message = _.result(jobResult, 'message'); + } else { + if (typeof jobResult == 'string') { + message = jobResult; + } + jobResult = null; } if (isJobId(jobId)) { this.id = jobId; @@ -440,6 +443,12 @@ function onJobStatus(error, res, body) { this._pollerId = _.delay(_.bind(this.status, this), this.statusInterval * 1000); return; } + var description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]), + errored = !jobResult || !jobResult.passed || reError.test(message) || reError.test(jobStatus), + failures = _.result(jobResult, 'failed'), + label = options.name + ':', + tunnel = this.tunnel; + if (errored || failures) { if (errored && this.attempts < this.retries) { this.restart();