Name: js-handler/node_modules/nodeunit/node_modules/tap/lib/tap-browser-harness.js
| 1: | // this is just a harness that pipes to stdout. |
| 2: | // It's the default one. |
| 3: | module.exports = BrowserHarness |
| 4: | |
| 5: | var BrowserHarness = global.TAP_Browser_Harness |
| 6: | , inherits = require("inherits") |
| 7: | , Results = require("./tap-results") |
| 8: | , Harness = require("./tap-harness") |
| 9: | , Test = require("./tap-test") |
| 10: | |
| 11: | inherits(BrowserHarness, Harness) |
| 12: | function BrowserHarness (outPipe) { |
| 13: | //console.error("calling BrowserHarness") |
| 14: | if (browserHarness) return browserHarness |
| 15: | if (!(this instanceof BrowserHarness)) { |
| 16: | return browserHarness = new BrowserHarness |
| 17: | } |
| 18: | browserHarness = global.TAP_Browser_Harness = this |
| 19: | Harness.call(this, Test) |
| 20: | |
| 21: | if (outPipe) this.output.pipe(outPipe) |
| 22: | |
| 23: | this.test = this.test.bind(this) |
| 24: | |
| 25: | this.plan = this.plan.bind(this) |
| 26: | |
| 27: | var output = this.output |
| 28: | this.on("childEnd", function (child) { |
| 29: | //console.error("childEnd in global harness") |
| 30: | //console.error(child.results) |
| 31: | // write out the stuff for this child. |
| 32: | //console.error("child.conf", child.conf) |
| 33: | |
| 34: | // maybe write some other stuff about the number of tests in this |
| 35: | // thing, etc. I dunno. |
| 36: | //console.error("child results", child.results) |
| 37: | this.results.list.forEach(function (res) { |
| 38: | //delete res.error |
| 39: | //console.error("child resuilt", res) |
| 40: | output.write(res) |
| 41: | }) |
| 42: | //console.error("wrote child results") |
| 43: | this.results.list.length = 0 |
| 44: | }) |
| 45: | |
| 46: | var streamEnded = false |
| 47: | this.on("end", function () { |
| 48: | //console.error("global ending the stream") |
| 49: | if (!streamEnded) { |
| 50: | this.results.list.forEach(function (res) { |
| 51: | output.write(res) |
| 52: | }) |
| 53: | this.results.list.length = 0 |
| 54: | output.end() |
| 55: | streamEnded = true |
| 56: | } |
| 57: | }) |
| 58: | |
| 59: | // TODO: handle global errors |
| 60: | // process.on("unhandledException", function (e) { |
| 61: | // this.bailout("unhandled exception: " + e.message) |
| 62: | // }) |
| 63: | } |
