Permalink
Browse files

Exit on input stream errors

Also add logging.
  • Loading branch information...
1 parent 430e66c commit 8872fd5d81c84ae18dc6b298ab833e087b002589 @daveyeu committed May 22, 2012
Showing with 66 additions and 16 deletions.
  1. +18 −3 node_modules/log_stream.js
  2. +22 −0 node_modules/logger.js
  3. +25 −13 spec/log_stream_spec.js
  4. +1 −0 spec/spec_helper.js
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -1,3 +1,5 @@
+require("./spec_helper.js");
+
describe("LogStream", function() {
var LogStream = require("log_stream");
var EventEmitter = require("events").EventEmitter;
@@ -13,21 +15,31 @@ describe("LogStream", function() {
});
});
- describe("when the input stream emits the 'end' event", function() {
- it("terminates the process", function() {
- var logStream = new LogStream(mockStream);
- spyOn(process, "exit");
- mockStream.emit("end");
- expect(process.exit).toHaveBeenCalled();
+ describe("input stream errors", function() {
+ var logStream = new LogStream(mockStream);
+
+ describe("when the input stream emits the 'end' event", function() {
+ it("terminates the process", function() {
+ spyOn(process, "exit");
+ mockStream.emit("end");
+ expect(process.exit).toHaveBeenCalled();
+ });
});
- });
- describe("when the input stream emits an 'error' event", function() {
- it("terminates the process with a non-zero error code", function() {
- var logStream = new LogStream(mockStream);
- spyOn(process, "exit");
- mockStream.emit("error", new Error("BOOM"));
- expect(process.exit).toHaveBeenCalledWith(1);
+ describe("when the input stream emits an 'error' event", function() {
+ it("terminates the process with a non-zero error code", function() {
+ spyOn(process, "exit");
+ mockStream.emit("error", new Error("BOOM"));
+ expect(process.exit).toHaveBeenCalledWith(1);
+ });
+ });
+
+ describe("when the input stream emits a 'close' event", function() {
+ it("terminates the process with a non-zero error code", function() {
+ spyOn(process, "exit")
+ mockStream.emit("close");
+ expect(process.exit).toHaveBeenCalledWith(1);
+ });
});
});
});
View
@@ -0,0 +1 @@
+require("logger").disabled = true;

0 comments on commit 8872fd5

Please sign in to comment.