Browse files

Fix #36, handle test file 404s.

  • Loading branch information...
1 parent e3938b1 commit 6925ea017edf16e506e140d209f9b2096407878f @reid reid committed Apr 11, 2012
Showing with 35 additions and 12 deletions.
  1. +5 −0 lib/cli.js
  2. +8 −0 lib/client.js
  3. +10 −3 lib/hub/agent.js
  4. +12 −9 lib/hub/batch.js
View
5 lib/cli.js
@@ -145,6 +145,11 @@ function submitBatch(client, tests, cb) {
error(" User-Agent: " + agent);
});
+ batch.on("agentError", function (agent, details) {
+ error(color.red(bad + " Error") + ": " + details.message);
+ error(" User-Agent: " + agent);
+ });
+
batch.on("agentComplete", function (agent) {
error(good, "Agent completed:", agent);
});
View
8 lib/client.js
@@ -76,6 +76,13 @@ util.inherits(ClientBatch, EventEmitter2);
*/
/**
+ * Error while handling an agent request.
+ * @event agentError
+ * @param {String} agent Agent name.
+ * @param {Object} details Exception details. Contains message property.
+ */
+
+/**
* Uncaught JavaScript error from an agent.
* @event agentScriptError
* @param {String} agent Agent name.
@@ -102,6 +109,7 @@ ClientBatch.prototype.onAck = function (err, id) {
self.batchSession.incomingBridge(self, "complete");
self.batchSession.incomingBridge(self, "agentComplete");
self.batchSession.incomingBridge(self, "agentResult");
+ self.batchSession.incomingBridge(self, "agentError");
self.batchSession.incomingBridge(self, "agentScriptError");
self.once("complete", function () {
View
13 lib/hub/agent.js
@@ -76,16 +76,23 @@ Agent.prototype.connect = function (socket) {
this.socketEmitter.add(socket);
};
-Agent.prototype.next = function () {
+Agent.prototype.nextURL = function () {
+ var url;
+
if (this.urlQueue.length) {
- this.socketEmitter.emit("navigate", this.urlQueue.shift());
+ url = this.urlQueue.shift();
this.waiting = false;
} else {
+ url = this.manager.hub.mountpoint;
this.waiting = true;
- this.socketEmitter.emit("navigate", this.manager.hub.mountpoint);
this.emit("complete");
}
+ return url;
+};
+
+Agent.prototype.next = function () {
+ this.socketEmitter.emit("navigate", this.nextURL());
return !this.waiting;
};
View
21 lib/hub/batch.js
@@ -162,17 +162,20 @@ Batch.prototype.handleFileRequest = function (server, filename) {
if (agentId) {
agent = batch.agents[agentId];
}
- /*
if (agent) {
- // TODO: Advance to next test with 302 Found.
- // Emit error for CLI.
+ batch.report("agentError", agent, {
+ message: "Unable to serve the file: " + filename
+ });
+ server.res.writeHead(302, {
+ "Location": agent.nextURL()
+ });
+ server.res.end();
+ } else {
+ server.res.writeHead(500, {
+ "content-type": "text/plain"
+ });
+ server.res.end("Unable to serve this file.");
}
- */
-
- server.res.writeHead(500, {
- "content-type": "text/plain"
- });
- server.res.end("Unable to serve this file.");
return;
}
batch.testServer.serve(server, filename, buffer);

0 comments on commit 6925ea0

Please sign in to comment.