From 869a361d096c24ce78efdc27d37e3a6d03ef15f9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 3 Nov 2013 12:49:15 -0800 Subject: [PATCH] Add underscore tests to sauce. --- .travis.yml | 8 ++ test/backbone.html | 40 +++++++++ test/underscore.html | 136 +++++++++++++++++++++---------- vendor/underscore/test/arrays.js | 3 + 4 files changed, 146 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index f031b4ffa..9e43fad6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,21 +65,29 @@ script: - "[ $SAUCELABS != false ] && true || [ $BUILD == false ] && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.min.js" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-compat-dev\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-compat-dev&compat=7\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-compat-dev\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-compat-dev\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-compat\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-compat&compat=7\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-compat\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-compat\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-modern-dev\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=modern-dev\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=modern-dev\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-modern\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-modern\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-modern\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=../dist/lodash.legacy.js\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=../dist/lodash.legacy.js&compat=7\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=../dist/lodash.legacy.js\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=../dist/lodash.legacy.js\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-legacy\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-legacy&compat=7\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-legacy\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-legacy\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=../dist/lodash.mobile.js\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=../dist/lodash.mobile.js\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=../dist/lodash.mobile.js\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/index.html?build=lodash-mobile\"" + - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-mobile\"" - "[ $SAUCELABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-mobile\"" diff --git a/test/backbone.html b/test/backbone.html index a303eced5..ab9725175 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -33,6 +33,46 @@ global_test_results = results; }); + // skip tests we intentionally fail or those with problems + (function() { + var skipped = { + 'Backbone.Collection': { + 'set with many models does not overflow the stack': true + } + }; + + QUnit.testStart(function(details) { + var test = QUnit.config.current, + skippedTests = skipped[details.module], + skippedAsserts = skippedTests && skippedTests[details.name]; + + if (!skippedAsserts) { + return; + } + if (skippedAsserts === true) { + test.expected = 0; + test.callback = _.noop; + return; + } + test.finish = _.wrap(test.finish, function(func) { + _.each(this.assertions, function(assert) { + var message = _.unescape(_.result(/^([\s\S]*?)<\/span>/.exec(assert.message), 1)), + died = _.result(/^Died on test #\d+/.exec(message), 0), + expected = _.unescape(_.result(/Expected: *<\/th>
([\s\S]*?)<\/pre>/.exec(assert.message), 1));
+
+							if ((message && _.contains(skippedAsserts, message)) ||
+							    (died && _.contains(skippedAsserts, died)) ||
+							    (expected && (_.contains(skippedAsserts, expected) ||
+									  _.contains(skippedAsserts, expected.replace(/\s+/g, '')))
+							    )) {
+							  assert.result = true;
+							}
+						});
+						func.call(this);
+					});
+				});
+			}());
+
 			// load Lo-Dash again to overwrite the existing `_` value
 			document.write('
diff --git a/test/underscore.html b/test/underscore.html
index 4d31aec1e..67eb7d70f 100644
--- a/test/underscore.html
+++ b/test/underscore.html
@@ -24,51 +24,104 @@