From 051f3499ecea470fe4a9c490ee14c3a0728fee6c Mon Sep 17 00:00:00 2001 From: Colin O'Byrne and JR Boyens Date: Wed, 24 Jul 2013 14:38:57 -0700 Subject: [PATCH] Revert "[Finishes #45476285] Add timeout support to async tests" This reverts commit 8f5d0beb8cebd4cba141db604aaae670fb6add4e. Async timeout support is just not ready for prime time. --- spec/core/EnvSpec.js | 49 ---------------------------------------- spec/core/SpySpec.js | 6 ++--- spec/support/dev_boot.js | 3 --- src/core/Env.js | 7 +----- src/core/QueueRunner.js | 37 ++++-------------------------- src/core/Spec.js | 1 - 6 files changed, 8 insertions(+), 95 deletions(-) diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 2d815ecc..9fb5b08e 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -291,55 +291,6 @@ describe("Env integration", function() { env.execute(); }); - - describe("with a mock clock", function() { - beforeEach(function() { - jasmine.getEnv().clock.install(); - }); - - afterEach(function() { - jasmine.getEnv().clock.uninstall(); - }); - - it("should not hang on async specs that forget to call done()", function(done) { - var env = new j$.Env(), - reporter = jasmine.createSpyObj('fakeReporter', [ - "jasmineStarted", - "jasmineDone", - "suiteStarted", - "suiteDone", - "specStarted", - "specDone" - ]); - - env.addReporter(reporter); - - env.describe("tests", function() { - env.it("async spec that will hang", function(underTestCallback) { - env.expect(true).toBeTruthy(); - }); - - env.it("after async spec", function() { - env.expect(true).toBeTruthy(); - }); - }); - - env.execute(); - - reporter.jasmineDone.and.callFake(function() { - expect(reporter.jasmineStarted).toHaveBeenCalledWith({ - totalSpecsDefined: 2 - }); - - expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'passed'})); - expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'})); - - done(); - }); - - jasmine.getEnv().clock.tick(60001); - }); - }); // TODO: something is wrong with this spec it("should report as expected", function(done) { diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index a77d469c..c42db911 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -15,8 +15,6 @@ describe('Spies', function () { }); it("warns the user that we indend to overwrite an existing property", function() { - TestClass.prototype.someFunction.and = "existing"; - expect(function() { j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction); }).toThrowError("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon"); @@ -25,8 +23,8 @@ describe('Spies', function () { it("adds a spyStrategy and callTracker to the spy", function() { var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction); - expect(spy.and).toEqual(jasmine.any(j$.SpyStrategy)); - expect(spy.calls).toEqual(jasmine.any(j$.CallTracker)); + expect(spy.and).toEqual(jasmine.any(j$.SpyStrategy); + expect(spy.calls).toEqual(jasmine.any(j$.CallTracker); }); }); diff --git a/spec/support/dev_boot.js b/spec/support/dev_boot.js index cdb3a32e..3a6572d8 100644 --- a/spec/support/dev_boot.js +++ b/spec/support/dev_boot.js @@ -6,9 +6,6 @@ var env = jasmine.getEnv(); - SUPER_TIMEOUT = setTimeout; - SUPER_CLEAR_TIMEOUT = clearTimeout; - var jasmineInterface = { describe: function(description, specDefinitions) { return env.describe(description, specDefinitions); diff --git a/src/core/Env.js b/src/core/Env.js index c36231b0..e21ea96f 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -1,14 +1,13 @@ getJasmineRequireObj().Env = function(j$) { function Env(options) { options = options || {}; - + var self = this; var global = options.global || j$.getGlobal(); var catchExceptions = true; var realSetTimeout = j$.getGlobal().setTimeout; - var realClearTimeout = j$.getGlobal().clearTimeout; this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler()); var spies = []; @@ -121,13 +120,9 @@ getJasmineRequireObj().Env = function(j$) { } } - var asyncSpecTimeout = 60000; - var queueRunnerFactory = function(options) { options.catchException = self.catchException; options.clearStack = options.clearStack || clearStack; - options.realTimer = { setTimeout: realSetTimeout, clearTimeout: realClearTimeout }; - options.asyncSpecTimeout = asyncSpecTimeout; new j$.QueueRunner(options).run(options.fns, 0); }; diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index 9739ef88..ac615053 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -6,11 +6,6 @@ getJasmineRequireObj().QueueRunner = function() { this.clearStack = attrs.clearStack || function(fn) {fn();}; this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; - - this.timer = attrs.realTimer; - this.asyncSpecTimeout = attrs.asyncSpecTimeout || 60000; - - this.leaf = attrs.leaf || false; } QueueRunner.prototype.execute = function() { @@ -21,23 +16,16 @@ getJasmineRequireObj().QueueRunner = function() { var length = fns.length, self = this, iterativeIndex; - - var nextIteration = function(currentIteration) { - return function() { - self.run(fns, currentIteration + 1); - }; - }; for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { var fn = fns[iterativeIndex]; - if (fn.length > 0) { - var attemptSuccessful = attempt(fn, nextIteration(iterativeIndex)); + var attemptSuccessful = attempt(function() { + fn.call(self, function() { self.run(fns, iterativeIndex + 1); }); + }); if(attemptSuccessful) { return; - } else { - // TODO cleanup the timeout ? } } else { attempt(function() { fn.call(self); }); @@ -50,24 +38,9 @@ getJasmineRequireObj().QueueRunner = function() { this.clearStack(this.onComplete); } - function attempt(fn, done) { - var timeout; - + function attempt(fn) { try { - if (self.leaf) { - timeout = self.timer.setTimeout(function() { - self.onException(new Error("timeout")); - done(); - }, self.asyncSpecTimeout); - } - - var next = function() { - if (self.leaf) { self.timer.clearTimeout(timeout); } - done(); - }; - - fn.call(self, next); - + fn(); return true; } catch (e) { self.onException(e); diff --git a/src/core/Spec.js b/src/core/Spec.js index e63f2c17..6f051a68 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -57,7 +57,6 @@ getJasmineRequireObj().Spec = function() { this.queueRunner({ fns: allFns, - leaf: true, onException: function(e) { if (Spec.isPendingSpecException(e)) { self.pend();