Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Only suite:configuration emits full ua/runtime description
Browse files Browse the repository at this point in the history
All other events emit only the uuid. Consumers should use the
suite:configuration event to connect a human-readable ua description with
a specific uuid.

This vastly reduces the amount of data transported by the test runner, while
not loosing any data _and_ clearing up possible ambiguity in having the
ua description emitted multiple times ("will this vary between events?")
  • Loading branch information
cjohansen committed Nov 23, 2013
1 parent 4eaa102 commit 1e7c966
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions lib/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
};

function emit(runner, event, test, err, thisp) {
var data = { name: test.name, runtime: runner.runtime };
var data = { name: test.name, uuid: runner.runtime && runner.runtime.uuid };
if (err) { data.error = err; }
if (typeof test.func === "string") { data.comment = test.func; }
if (thisp) { data.testCase = thisp; }
Expand All @@ -72,7 +72,7 @@

function testResult(runner, test, err) {
if (!test) {
err.runtime = runner.runtime;
err.uuid = runner.runtime && runner.runtime.uuid;
return runner.emit("uncaughtException", err);
}
if (test.complete) { return; }
Expand Down Expand Up @@ -103,7 +103,7 @@

function emitUnsupported(runner, context, requirements) {
runner.emit("context:unsupported", {
runtime: runner.runtime,
uuid: runner.runtime && runner.runtime.uuid,
context: context,
unsupported: requirements
});
Expand Down Expand Up @@ -476,15 +476,15 @@
testResult(this, this.currentTest, err);
}, this));
var d = when.defer();
this.emit("suite:start", { runtime: this.runtime });
this.emit("suite:start", { uuid: this.runtime && this.runtime.uuid });
if (this.runtime) { emitConfiguration(this, ctxs); }
if (this.focusMode) {
this.emit("runner:focus", { runtime: this.runtime });
this.emit("runner:focus", { uuid: this.runtime && this.runtime.uuid });
}
this.results.contexts = ctxs.length;
this.runContexts(ctxs).then(_.bind(function () {
var res = prepareResults(this.results);
res.runtime = this.runtime;
res.uuid = this.runtime && this.runtime.uuid;
this.emit("suite:end", res);
d.resolve(res);
}, this), d.reject);
Expand All @@ -511,7 +511,7 @@
var d = when.defer(), s = this, thisp, ctx;
var emitAndResolve = function () {
s.emit("context:end", _.extend(context, {
runtime: s.runtime
uuid: s.runtime && s.runtime.uuid
}));
d.resolve();
};
Expand All @@ -522,7 +522,7 @@
);
};
this.emit("context:start", _.extend(context, {
runtime: this.runtime
uuid: this.runtime && this.runtime.uuid
}));
asyncWhen(context).then(function (c) {
ctx = c;
Expand Down Expand Up @@ -553,7 +553,7 @@
err.message = context.name + " " + thisp.name(prop) + "(n) " +
(/Timeout/.test(err.name) ?
"timed out" : "failed") + ": " + err.message;
err.runtime = s.runtime;
err.uuid = s.runtime && s.runtime.uuid;
s.emit("uncaughtException", err);
d.reject(err);
};
Expand Down
34 changes: 17 additions & 17 deletions test/test-runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@

this.runSuite([context], done(function (listeners) {
var ctx = listeners["suite:start"].args[0][0];
assert.isObject(ctx.runtime);
assert.isString(ctx.uuid);
}));
},

Expand All @@ -2207,8 +2207,8 @@

this.runSuite([context], done(function (listeners) {
var ctx = listeners["context:start"].args[0][0];
assert.isObject(ctx.runtime);
delete ctx.runtime;
assert.isString(ctx.uuid);
delete ctx.uuid;
assert.equals(ctx, context);
}));
},
Expand All @@ -2218,8 +2218,8 @@

this.runSuite([context], done(function (listeners) {
var ctx = listeners["context:end"].args[0][0];
assert.isObject(ctx.runtime);
delete ctx.runtime;
assert.isString(ctx.uuid);
delete ctx.uuid;
assert.equals(ctx, context);
}));
},
Expand All @@ -2231,8 +2231,8 @@

this.runSuite([context], done(function (listeners) {
var arg = listeners["context:unsupported"].args[0][0];
assert.isObject(arg.runtime);
delete arg.runtime;
assert.isString(arg.uuid);
delete arg.uuid;
assert.equals(arg, {
context: context,
unsupported: ["Feature A"]
Expand All @@ -2248,7 +2248,7 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:setUp"].args;
assert.isObject(args[0][0].runtime);
assert.isString(args[0][0].uuid);
assert.equals(args[0][0].name, "test1");
assert(context.testCase.isPrototypeOf(args[0][0].testCase));
}));
Expand All @@ -2262,7 +2262,7 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:tearDown"].args;
assert.isObject(args[0][0].runtime);
assert.isString(args[0][0].uuid);
assert.equals("test1", args[0][0].name);
assert(context.testCase.isPrototypeOf(args[0][0].testCase));
}));
Expand All @@ -2276,7 +2276,7 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:start"].args;
assert.isObject(args[0][0].runtime);
assert.isString(args[0][0].uuid);
assert.equals(args[0][0].name, "test1");
assert(context.testCase.isPrototypeOf(args[0][0].testCase));
}));
Expand All @@ -2290,7 +2290,7 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:error"].args[0];
assert.isObject(args[0].runtime);
assert.isString(args[0].uuid);
assert.equals(args[0].name, "test1");
assert.equals(args[0].error.name, "TypeError");
assert.equals(args[0].error.message, "");
Expand All @@ -2306,7 +2306,7 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:failure"].args[0];
assert.isObject(args[0].runtime);
assert.isString(args[0].uuid);
assert.equals(args[0].name, "test1");
assert.equals(args[0].error.name, "AssertionError");
assert.equals(args[0].error.message, "");
Expand All @@ -2327,8 +2327,8 @@

this.runSuite([context], done(function (listeners) {
var args = listeners["test:success"].args[0];
assert.isObject(args[0].runtime);
delete args[0].runtime;
assert.isString(args[0].uuid);
delete args[0].uuid;
assert.equals(args, [{ name: "test1", assertions: 2 }]);
}));
},
Expand Down Expand Up @@ -2365,7 +2365,7 @@

this.runSuite([context, context2], done(function (listeners) {
var args = listeners["suite:end"].args[0];
assert.isObject(args[0].runtime);
assert.isString(args[0].uuid);
assert.equals(args[0].contexts, 2);
assert.equals(args[0].tests, 10);
assert.equals(args[0].errors, 2);
Expand Down Expand Up @@ -2455,7 +2455,7 @@

setTimeout(done(function () {
assert(listener.calledOnce);
assert.isObject(listener.args[0][0].runtime);
assert.isString(listener.args[0][0].uuid);
assert.match(listener.args[0][0].message, /Damnit/);
}), 25);

Expand Down Expand Up @@ -2826,7 +2826,7 @@
});

this.runner.on("runner:focus", done(function (e) {
assert.isObject(e.runtime);
assert.isString(e.uuid);
}));
this.runner.runSuite([context]);
}
Expand Down

0 comments on commit 1e7c966

Please sign in to comment.