Name: js-handler/node_modules/nodeunit/lib/reporters/tap.js 
1:
/**
2:
 * Module dependencies
3:
 */
4:
 
5:
var nodeunit = require('../nodeunit'),
6:
    path = require('path'),
7:
    assert = require('tap').assert,
8:
    TapProducer = require('tap').Producer;
9:
 
10:
/**
11:
 * Reporter info string
12:
 */
13:
 
14:
exports.info = "TAP output";
15:
 
16:
/**
17:
 * Run all tests within each module, reporting the results to the command-line.
18:
 *
19:
 * @param {Array} files
20:
 * @api public
21:
 */
22:
 
23:
exports.run = function (files, options) {
24:
 
25:
    if (!options) {
26:
        // load default options
27:
        var content = fs.readFileSync(
28:
            __dirname + '/../../bin/nodeunit.json', 'utf8'
29:
        );
30:
        options = JSON.parse(content);
31:
    }
32:
 
33:
    var paths = files.map(function (p) {
34:
        return path.join(process.cwd(), p);
35:
    });
36:
    var output = new TapProducer();
37:
    output.pipe(process.stdout);
38:
 
39:
    nodeunit.runFiles(paths, {
40:
        testStart: function (name) {
41:
            output.write(name.toString());
42:
        },
43:
        testDone: function (name, assertions) {
44:
            assertions.forEach(function (e) {
45:
                var extra = {};
46:
                if (e.error) {
47:
                    extra.error = {
48:
                        name: e.error.name,
49:
                        message: e.error.message,
50:
                        stack: e.error.stack.split(/\n/).filter(function (line) {
51:
                            // exclude line of "types.js"
52:
                            return ! RegExp(/types.js:83:39/).test(line);
53:
                        }).join('\n')
54:
                    };
55:
                    extra.wanted = e.error.expected;
56:
                    extra.found = e.error.actual;
57:
                }
58:
                output.write(assert(e.passed(), e.message, extra));
59:
            });
60:
        },
61:
        done: function (assertions) {
62:
            output.end();
63:
        }
64:
    });
65:
};