Permalink
Browse files

[tap] refactored tests to folders

* added tap runner script from isaacs
* refactored test run script to support both vows and tap
  • Loading branch information...
1 parent a0eb4e7 commit 524a0353e43cb838ee3af81a1ab63a8133494e99 @dscape committed Sep 10, 2011
Showing with 52 additions and 8 deletions.
  1. +43 −0 test/bin/tap.js
  2. +5 −4 test/run
  3. +1 −1 test/{ → tap}/tap.js
  4. +1 −1 test/{ → vows}/foo.js
  5. +1 −1 test/{ → vows}/select.js
  6. +1 −1 test/{ → vows}/use.js
View
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+// credit: https://github.com/isaacs/node-tap
+var argv = process.argv.slice(2)
+ , path = require("path")
+ , Runner = require("tap-runner")
+ , r = new Runner(argv, null)
+ , TapProducer = require("tap-producer")
+
+if (process.env.TAP || process.env.TAP_DIAG) {
+ r.pipe(process.stdout)
+} else {
+ r.on("file", function (file, results, details) {
+ var s = (details.ok ? "" : "not ") + "ok "+results.name
+ , n = details.pass + "/" + details.testsTotal
+ , dots = new Array(Math.max(1, 40 - s.length - n.length)).join(".")
+ console.log("%s %s %s", s, dots, n)
+ if (details.ok) {
+ if (details.skip) {
+ console.log(" skipped: %s", details.skipTotal)
+ }
+ } else {
+ // console.error(details)
+ console.log(" Command: %s", results.command)
+ console.log(" " + TapProducer.encode(details.list)
+ .split(/\n/).join("\n "))
+ }
+ })
+ r.on("end", function () {
+ //console.log(r)
+ var s = "total"
+ , n = r.results.pass + "/" + r.results.testsTotal
+ , dots = new Array(40 - s.length - n.length).join(".")
+ , ok = r.results.ok ? "ok" : "not ok"
+ console.log("%s %s %s\n\n%s", s, dots, n, ok)
+ process.stdout.flush()
+ })
+}
+
+
+
+r.on("end", function () {
+ process.exit(r.results.tests - r.results.pass)
+})
View
@@ -1,7 +1,8 @@
#!/bin/bash
# sudo npm install -g vows
tests=$(dirname $0)
-for s in $(ls -d $tests/);
-do
- for f in $s*.js; do node $f; done;
-done;
+for s in $(ls -d $tests/vows);
+do
+ for f in $s/*.js; do node $f; done;
+done;
+$tests/bin/tap.js $tests/tap
@@ -1,4 +1,4 @@
-var ensure = require('../ensure').use('tap')
+var ensure = require('../../ensure').use('tap')
, tests = exports
;
@@ -1,4 +1,4 @@
-var ensure = require('../ensure')
+var ensure = require('../../ensure')
, assert = require('assert')
, tests = exports
;
@@ -1,4 +1,4 @@
-var ensure = require('../ensure')
+var ensure = require('../../ensure')
, assert = require('assert')
, tests = exports;
@@ -1,4 +1,4 @@
-var ensure = require('../ensure').use('vows')
+var ensure = require('../../ensure').use('vows')
, assert = require('assert')
, tests = exports
;

0 comments on commit 524a035

Please sign in to comment.