Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Upate to make re-running tests more efficient, #21

Open
wants to merge 2 commits into from

2 participants

Steven dkonecny
Steven

This request should eliminate the need to --reset (and hence re-load and re-parse all test files) on each test run. There seems to be some subtlety WRT to how plugins are loaded by jstd, so a --reset is needed the first run, but none should be necessary after that.

svelez added some commits
Steven svelez Cleaning up on test page reloads.
Track which source page each intercepted function call came from
so that when that source page is reloaded, due to a change, the
previously intercepted functions for that page can be released.

Then newly intercepted function calls will not look like duplicate
test cases.
d00fe6a
Steven svelez Improve intercept clean up.
Change how the intercepts for a page are tracked.  Hopefully, this
resetting of an array will be more efficient than the splicing that
was happening earlier.
956ace2
dkonecny

I have not tested this patch yet but as I wrote in the issue 20, fix like this one is very desirable. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Feb 08, 2012
Steven svelez Cleaning up on test page reloads.
Track which source page each intercepted function call came from
so that when that source page is reloaded, due to a change, the
previously intercepted functions for that page can be released.

Then newly intercepted function calls will not look like duplicate
test cases.
d00fe6a
Feb 11, 2012
Steven svelez Improve intercept clean up.
Change how the intercepts for a page are tracked.  Hopefully, this
resetting of an array will be more efficient than the splicing that
was happening earlier.
956ace2
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 21 additions and 6 deletions. Show diff stats Hide diff stats

  1. +21 6 src/JasmineAdapter.js
27 src/JasmineAdapter.js
@@ -102,7 +102,7 @@ Reporter.prototype.reportRunnerResults = function(){
102 102 };
103 103
104 104
105   -var collectMode = true, intercepted = {};
  105 +var collectMode = true, intercepted = {}, lastFile = undefined;
106 106
107 107 describe = intercept('describe');
108 108 beforeEach = intercept('beforeEach');
@@ -115,6 +115,17 @@ jstestdriver.pluginRegistrar.register({
115 115
116 116 name: 'jasmine',
117 117
  118 + loadSource: function(file, onSourceLoadedCallback) {
  119 + var method;
  120 + lastFile = file.fileSrc;
  121 + // Remove all the intercepted methods for this file
  122 + for (method in intercepted) {
  123 + if (intercepted[method][lastFile]) {
  124 + intercepted[method][lastFile] = [];
  125 + }
  126 + }
  127 + },
  128 +
118 129 getTestRunsConfigurationFor: function(testCaseInfos, expressions, testRunsConfiguration) {
119 130 for (var i = 0; i < testCaseInfos.length; i++) {
120 131 if (testCaseInfos[i].getType() == JASMINE_TYPE) {
@@ -138,17 +149,21 @@ jstestdriver.pluginRegistrar.register({
138 149 });
139 150
140 151 function intercept(method){
141   - var bucket = intercepted[method] = [], method = window[method];
  152 + var bucket = intercepted[method] = {}, method = window[method];
142 153 return function(desc, fn){
143   - if (collectMode) bucket.push(function(){ method(desc, fn); });
144   - else method(desc, fn);
  154 + if (collectMode) {
  155 + if (!bucket[lastFile]) bucket[lastFile] = [];
  156 + bucket[lastFile].push(function(){ method(desc, fn); });
  157 + } else method(desc, fn);
145 158 };
146 159 }
147 160
148 161 function playback(){
149 162 for (var method in intercepted){
150   - var bucket = intercepted[method];
151   - for (var i = 0, l = bucket.length; i < l; i++) bucket[i]();
  163 + for (var file in intercepted[method]) {
  164 + var bucket = intercepted[method][file];
  165 + for (var i = 0, l = bucket.length; i < l; i++) bucket[i]();
  166 + }
152 167 }
153 168 }
154 169

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.