Permalink
Browse files

GH-18: Merged tap-global-harness, git history included.

  • Loading branch information...
2 parents bef4590 + 0dd54db commit 74d3be34b78ad4d2f6c6a7fd85e67d68e14390cc @kusor kusor committed Nov 17, 2011
Showing with 131 additions and 4 deletions.
  1. +63 −0 browser-harness.js
  2. +67 −0 global-harness.js
  3. +1 −4 package.json
View
@@ -0,0 +1,63 @@
+// this is just a harness that pipes to stdout.
+// It's the default one.
+module.exports = BrowserHarness
+
+var BrowserHarness = global.TAP_Browser_Harness
+ , inherits = require("inherits")
+ , Results = require("tap-results")
+ , Harness = require("tap-harness")
+ , Test = require("tap-test")
+
+inherits(BrowserHarness, Harness)
+function BrowserHarness (outPipe) {
+ //console.error("calling BrowserHarness")
+ if (browserHarness) return browserHarness
+ if (!(this instanceof BrowserHarness)) {
+ return browserHarness = new BrowserHarness
+ }
+ browserHarness = global.TAP_Browser_Harness = this
+ BrowserHarness.super.call(this, Test)
+
+ if (outPipe) this.output.pipe(outPipe)
+
+ this.test = this.test.bind(this)
+
+ this.plan = this.plan.bind(this)
+
+ var output = this.output
+ this.on("childEnd", function (child) {
+ //console.error("childEnd in global harness")
+ //console.error(child.results)
+ // write out the stuff for this child.
+ //console.error("child.conf", child.conf)
+ output.write(child.conf.name || "(unnamed test)")
+ // maybe write some other stuff about the number of tests in this
+ // thing, etc. I dunno.
+ //console.error("child results", child.results)
+ this.results.list.forEach(function (res) {
+ //delete res.error
+ //console.error("child resuilt", res)
+ output.write(res)
+ })
+ //console.error("wrote child results")
+ this.results.list.length = 0
+ })
+
+ var streamEnded = false
+ this.on("end", function () {
+ //console.error("global ending the stream")
+ if (!streamEnded) {
+ this.results.list.forEach(function (res) {
+ output.write(res)
+ })
+ this.results.list.length = 0
+ output.end()
+ streamEnded = true
+ }
+ })
+
+ // TODO: handle global errors
+ // process.on("unhandledException", function (e) {
+ // this.bailout("unhandled exception: " + e.message)
+ // })
+}
View
@@ -0,0 +1,67 @@
+// this is just a harness that pipes to stdout.
+// It's the default one.
+module.exports = GlobalHarness
+
+var globalHarness = global.TAP_Global_Harness
+ , inherits = require("inherits")
+ , Results = require("tap-results")
+ , Harness = require("tap-harness")
+ , Test = require("tap-test")
+
+inherits(GlobalHarness, Harness)
+function GlobalHarness () {
+ //console.error("calling GlobalHarness")
+ if (globalHarness) return globalHarness
+ if (!(this instanceof GlobalHarness)) {
+ return globalHarness = new GlobalHarness
+ }
+ globalHarness = global.TAP_Global_Harness = this
+ GlobalHarness.super.call(this, Test)
+
+ this.output.pipe(process.stdout)
+ //this.output.on("data", function () {
+ // process.nextTick(process.stdout.flush.bind(process.stdout))
+ //})
+
+ this.test = this.test.bind(this)
+
+ this.plan = this.plan.bind(this)
+
+ var output = this.output
+ this.on("childEnd", function (child) {
+ //console.error("childEnd in global harness")
+ //console.error(child.results)
+ // write out the stuff for this child.
+ //console.error("child.conf", child.conf)
+ output.write(child.conf.name || "(unnamed test)")
+ // maybe write some other stuff about the number of tests in this
+ // thing, etc. I dunno.
+ //console.error("child results", child.results)
+ this.results.list.forEach(function (res) {
+ //delete res.error
+ //console.error("child resuilt", res)
+ output.write(res)
+ })
+ //console.error("wrote child results")
+ this.results.list.length = 0
+ })
+
+ var streamEnded = false
+ this.on("end", function () {
+ //console.error("global ending the stream")
+ if (!streamEnded) {
+ this.results.list.forEach(function (res) {
+ output.write(res)
+ })
+ this.results.list.length = 0
+ output.end()
+ streamEnded = true
+ }
+ })
+
+ //this.on("end", this.output.end.bind(this.output))
+
+ process.on("unhandledException", function (e) {
+ this.bailout("unhandled exception: " + e.message)
+ })
+}
View
@@ -1,13 +1,11 @@
-<<<<<<< HEAD
{ "name" : "tap"
, "version" : "0.0.13"
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)"
, "description" : "A Test-Anything-Protocol library"
, "bin" : "bin/tap.js"
, "main" : "lib/main.js"
, "dependencies" :
- { "tap-global-harness" : "0.x"
- , "tap-results" : "0.x"
+ { "tap-results" : "0.x"
, "tap-consumer" : "0.x"
, "inherits" : "*"
, "yamlish" : "*"
@@ -16,7 +14,6 @@
, "bundledDependencies" :
[ "inherits"
, "tap-consumer"
- , "tap-global-harness"
, "tap-results"
, "yamlish"
]

0 comments on commit 74d3be3

Please sign in to comment.