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