Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add example of reformating test output.

  • Loading branch information...
commit c2c9c9c755b434bb2caac3a7270975755d820e6e 1 parent 1c89c40
@jcoglan authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 test/examples/reformat.js
View
25 test/examples/reformat.js
@@ -0,0 +1,25 @@
+// This script reads a JS.Test JSON output stream from stdin and reformats it
+// using any of the terminal-based test reporters, e.g. dot, spec, error, tap.
+//
+// Try it out on the JS.Test suite:
+//
+// $ node test/console -f json | node test/examples/reformat -f tap
+
+JSCLASS_PATH = 'build/src'
+require('../../' + JSCLASS_PATH + '/loader')
+JS.require('JS.Test')
+
+var options = require('nopt')({format: String}),
+ R = JS.Test.Reporters,
+ Printer = R.find(options.format),
+ reporter = new R.Composite(),
+ reader = new R.JSON.Reader(reporter)
+
+reporter.addReporter(new Printer())
+reporter.addReporter(new R.ExitStatus())
+
+process.stdin.on('data', function(data) {
+ data.toString().split('\n').forEach(reader.method('read'))
+})
+process.stdin.resume()
+
Please sign in to comment.
Something went wrong with that request. Please try again.