Permalink
Browse files

Remove extracted wiring

  • Loading branch information...
1 parent 557a08f commit f4c0005fdb1351e7ed316e8380ced031fa27c9ea @cjohansen cjohansen committed May 6, 2012
Showing with 12 additions and 96 deletions.
  1. +1 −0 jsTestDriver.conf
  2. +10 −95 lib/buster-test-cli/browser/wiring.js
  3. +1 −1 test/browser/wiring-test.js
View
@@ -31,6 +31,7 @@ load:
- node_modules/buster-test/lib/buster-test/reporters/json-proxy.js
- node_modules/sinon-buster/lib/sinon-buster.js
- node_modules/buster/lib/buster/buster-wiring.js
+ - node_modules/buster/lib/buster/browser-wiring.js
- lib/buster-test-cli/browser/*.js
- test/browser/test-helper.js
- test/browser/*.js
@@ -1,79 +1,15 @@
/*jslint browser: true*/
(function (B) {
- function catchUncaughtErrors(emitter) {
- window.onerror = function (message, url, line) {
- if (arguments.length === 3) {
- var cp = buster.env.contextPath;
- var index = (url || "").indexOf(cp);
- url = "." + url.slice(index + cp.length);
-
- if (line === 1 && message === "Error loading script") {
- message = "Unable to load script " + url;
- } else {
- message = url + ":" + line + " " + message;
- }
- }
-
- emitter.emit("uncaughtException", {
- name: "UncaughtError",
- message: message
- });
-
- return true;
- };
- }
-
- function connectLogger(emitter) {
- B.console.on("log", function (msg) {
- emitter.emit("log", msg);
- });
- }
-
- function collectTestCases() {
- var contexts = [];
- B.addTestContext = function (context) { contexts.push(context); };
- B.testCase.onCreate = B.addTestContext;
- B.spec.describe.onCreate = B.addTestContext;
-
- return contexts;
- }
-
- function cleanEnvironment(runner) {
- var scripts = document.body.getElementsByTagName("script"), script;
- while ((script = scripts[0])) {
- script.parentNode.removeChild(script);
- }
-
- var env = buster.browserEnv.create(document.body);
- env.listen(runner);
- }
-
- function connectTestRunner(emitter) {
- var ctxts = collectTestCases();
- var ready, started, config;
-
- function startRun() {
- if (!ready || !started) { return; }
- var runner = B.testRunner.create(config);
- var reporter = B.reporters.jsonProxy.create(emitter);
- reporter.listen(runner);
- cleanEnvironment(runner);
- if (config.captureConsole) { buster.captureConsole(); }
- runner.runSuite(buster.testContext.compile(ctxts, config.filters));
- }
+ function wireTestRunner(emitter) {
+ var runner = B.testRunner.create();
+ var reporter = B.reporters.jsonProxy.create(emitter);
+ reporter.listen(runner);
+ var wiring = B.wire.testRunner(runner);
+ B.run = wiring.run;
emitter.on("tests:run", function (msg) {
- config = (msg && msg.data) || {};
- ready = true;
- var autoRun = !config.hasOwnProperty("autoRun") || config.autoRun;
- started = started || autoRun;
- startRun();
+ wiring.ready(msg && msg.data);
});
-
- return function () {
- started = true;
- startRun();
- };
}
B.configureTestClient = function (emitter) {
@@ -96,11 +32,9 @@
emitReady(emitter);
});
- catchUncaughtErrors(emitter);
- connectLogger(emitter);
- B.run = connectTestRunner(emitter);
-
- B.env = B.env || {};
+ B.wire.uncaughtErrors(emitter);
+ B.wire.logger(emitter);
+ wireTestRunner(emitter);
};
if (B.publish && B.subscribe) {
@@ -111,23 +45,4 @@
B.on = B.bind(emitter, "on");
B.configureTestClient(emitter);
}
-
- // TMP Performance fix
- (function () {
- var i = 0;
-
- B.nextTick = function (cb) {
- i += 1;
-
- if (i === 10) {
- setTimeout(function () {
- cb();
- }, 0);
-
- i = 0;
- } else {
- cb();
- }
- };
- }());
}(buster));
@@ -176,7 +176,7 @@
this.emitter.emit("tests:run");
- assertEquals(counts, [1, 2]);
+ assertEquals(counts.sort(), [1, 2]);
},
"should filter contexts prior to running": function () {

0 comments on commit f4c0005

Please sign in to comment.