Attempt to detect more false test errors.

This commit is contained in:
John-David Dalton
2014-05-19 09:08:15 -07:00
parent 1111c20d54
commit 891ebb8ff6
4 changed files with 38 additions and 12 deletions

View File

@@ -42,6 +42,13 @@
} }
}; };
// avoid reporting tests to Sauce Labs when script errors occur
if (ui.isSauceLabs) {
window.onerror = function(message) {
QUnit.config.done.length = 0;
global_test_results = { 'message': message };
};
}
// load Lo-Dash // load Lo-Dash
if (!ui.isModularize) { if (!ui.isModularize) {
document.write('<script src="' + ui.buildPath + '"><\/script>'); document.write('<script src="' + ui.buildPath + '"><\/script>');

View File

@@ -152,6 +152,15 @@
delete String.prototype._contains; delete String.prototype._contains;
} }
QUnit.config.hidepassed = true;
// avoid reporting tests to Sauce Labs when script errors occur
if (ui.isSauceLabs) {
window.onerror = function(message) {
QUnit.config.done.length = 0;
global_test_results = { 'message': message };
};
}
// load Lo-Dash and expose it to the bad extensions/shims // load Lo-Dash and expose it to the bad extensions/shims
if (!ui.isModularize) { if (!ui.isModularize) {
addBizarroMethods(); addBizarroMethods();
@@ -159,8 +168,6 @@
} }
</script> </script>
<script> <script>
QUnit.config.hidepassed = true;
// store Lo-Dash to test for bad extensions/shims // store Lo-Dash to test for bad extensions/shims
if (!ui.isModularize) { if (!ui.isModularize) {
var lodashBizarro = window._; var lodashBizarro = window._;

View File

@@ -33,7 +33,7 @@ var maxJobRetries = 3,
/** Used as the static file server middleware */ /** Used as the static file server middleware */
var mount = ecstatic({ var mount = ecstatic({
'cache': false, 'cache': 'no-cache',
'root': process.cwd() 'root': process.cwd()
}); });
@@ -55,6 +55,9 @@ var push = Array.prototype.push;
/** Used to detect error messages */ /** Used to detect error messages */
var reError = /\berror\b/i; var reError = /\berror\b/i;
/** Used to detect valid job ids */
var reJobId = /^[a-z0-9]{32}$/;
/** Used to display the wait throbber */ /** Used to display the wait throbber */
var throbberDelay = 500, var throbberDelay = 500,
waitCount = -1; waitCount = -1;
@@ -70,7 +73,7 @@ var advisor = getOption('advisor', true),
maxDuration = getOption('maxDuration', 360), maxDuration = getOption('maxDuration', 360),
port = ports[Math.min(_.sortedIndex(ports, getOption('port', 9001)), ports.length - 1)], port = ports[Math.min(_.sortedIndex(ports, getOption('port', 9001)), ports.length - 1)],
publicAccess = getOption('public', true), publicAccess = getOption('public', true),
queueTimeout = getOption('queueTimeout', 360), queueTimeout = getOption('queueTimeout', 600),
recordVideo = getOption('recordVideo', true), recordVideo = getOption('recordVideo', true),
recordScreenshots = getOption('recordScreenshots', false), recordScreenshots = getOption('recordScreenshots', false),
runner = getOption('runner', 'test/index.html').replace(/^\W+/, ''), runner = getOption('runner', 'test/index.html').replace(/^\W+/, ''),
@@ -399,7 +402,7 @@ function onJobStatus(error, res, body) {
platform = options.platforms[0], platform = options.platforms[0],
description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]), description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]),
elapsed = (_.now() - this.timestamp) / 1000, elapsed = (_.now() - this.timestamp) / 1000,
errored = !jobResult || reError.test(message), errored = !jobResult || reError.test(message) || reError.test(jobStatus),
expired = (elapsed >= queueTimeout && !_.contains(jobStatus, 'in progress')), expired = (elapsed >= queueTimeout && !_.contains(jobStatus, 'in progress')),
failures = _.result(jobResult, 'failed'), failures = _.result(jobResult, 'failed'),
label = options.name + ':', label = options.name + ':',
@@ -409,9 +412,11 @@ function onJobStatus(error, res, body) {
if (!this.running || this.stopping) { if (!this.running || this.stopping) {
return; return;
} }
this.id = jobId; if (reJobId.test(jobId)) {
this.result = jobResult; this.id = jobId;
this.url = jobUrl; this.result = jobResult;
this.url = jobUrl;
}
this.emit('status', jobStatus); this.emit('status', jobStatus);
if (!completed && !expired) { if (!completed && !expired) {
@@ -524,8 +529,8 @@ Job.prototype.remove = function(callback) {
this.removing = true; this.removing = true;
return this.stop(function() { return this.stop(function() {
var onRemove = _.bind(onJobRemove, this); var onRemove = _.bind(onJobRemove, this);
if (this.id == null) { if (!reJobId.test(this.id)) {
onRemove(); _.defer(onRemove);
return; return;
} }
request.del(_.template('https://saucelabs.com/rest/v1/${user}/jobs/${id}', this), { request.del(_.template('https://saucelabs.com/rest/v1/${user}/jobs/${id}', this), {
@@ -637,7 +642,7 @@ Job.prototype.stop = function(callback) {
this.checking = false; this.checking = false;
} }
var onStop = _.bind(onGenericStop, this); var onStop = _.bind(onGenericStop, this);
if (!this.running) { if (!this.running || !reJobId.test(this.id)) {
_.defer(onStop); _.defer(onStop);
return this; return this;
} }

View File

@@ -128,8 +128,15 @@
} }
}; };
// avoid reporting tests to Sauce Labs when script errors occur
if (ui.isSauceLabs) {
window.onerror = function(message) {
QUnit.config.done.length = 0;
global_test_results = { 'message': message };
};
}
// only excuse in Sauce Labs (buggy Safari and timers) // only excuse in Sauce Labs (buggy Safari and timers)
if (!ui.isSauceLabs) { else {
delete QUnit.config.excused.Chaining['select/reject/sortBy']; delete QUnit.config.excused.Chaining['select/reject/sortBy'];
delete QUnit.config.excused.Chaining['select/reject/sortBy in functional style']; delete QUnit.config.excused.Chaining['select/reject/sortBy in functional style'];
delete QUnit.config.excused.Functions['throttle repeatedly with results']; delete QUnit.config.excused.Functions['throttle repeatedly with results'];