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