Comparing version 0.9.3 to 0.9.4
@@ -82,3 +82,3 @@ /*! | ||
}); | ||
}); | ||
}, options.recursive); | ||
@@ -85,0 +85,0 @@ }; |
@@ -75,2 +75,3 @@ /*! | ||
testFullSpec: options.testFullSpec, | ||
recursive: options.recursive, | ||
moduleStart: function (name) { | ||
@@ -77,0 +78,0 @@ console.log('\n' + bold(name)); |
@@ -8,3 +8,3 @@ /** | ||
assert = require('tap').assert, | ||
TapProducer = require('tap').Producer, | ||
tap = require('tap'), | ||
fs = require('fs'); | ||
@@ -38,8 +38,8 @@ | ||
}); | ||
var output = new TapProducer(); | ||
output.pipe(process.stdout); | ||
tap.pipe(process.stdout); | ||
nodeunit.runFiles(paths, { | ||
testStart: function (name) { | ||
output.write(name.toString()); | ||
process.stdout.write(name.toString()); | ||
}, | ||
@@ -61,7 +61,7 @@ testDone: function (name, assertions) { | ||
} | ||
output.write(assert(e.passed(), e.message, extra)); | ||
tap.assert(e.passed(), e.message, extra); | ||
}); | ||
}, | ||
done: function (assertions) { | ||
output.end(); | ||
tap.end(); | ||
if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); | ||
@@ -68,0 +68,0 @@ } |
@@ -15,3 +15,4 @@ /*! | ||
Script = require('vm').Script, | ||
http = require('http'); | ||
http = require('http'), | ||
path = require('path'); | ||
@@ -56,7 +57,8 @@ | ||
* @param {Function} callback | ||
* @param {Boolean=} recursive | ||
* @api public | ||
*/ | ||
exports.modulePaths = function (paths, callback) { | ||
async.concat(paths, function (p, cb) { | ||
exports.modulePaths = function modulePaths(paths, callback, recursive) { | ||
recursive = (recursive === true); | ||
async.concatSeries(paths, function (p, cb) { | ||
fs.stat(p, function (err, stats) { | ||
@@ -87,6 +89,31 @@ if (err) { | ||
// sort filenames here, because Array.map changes order | ||
fullpaths.sort(); | ||
if (recursive) { | ||
// get all sub directories | ||
var directories = | ||
files | ||
.map(function(filename) { | ||
// resolve path first | ||
return path.resolve(p, filename); | ||
}) | ||
.filter(function(filename) { | ||
// fetch only directories | ||
return (fs.statSync(filename).isDirectory()); | ||
}); | ||
cb(null, fullpaths); | ||
// recursively call modulePaths() with sub directories | ||
modulePaths(directories, function(err, files) { | ||
if (!err) { | ||
cb(null, fullpaths.concat(files).sort()) | ||
} else { | ||
cb(err); | ||
} | ||
}, recursive); | ||
} else { | ||
// sort filenames here, because Array.map changes order | ||
fullpaths.sort(); | ||
// finish | ||
cb(null, fullpaths); | ||
} | ||
}); | ||
@@ -93,0 +120,0 @@ } |
{ | ||
"name": "nodeunit", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Easy unit testing for node.js and the browser.", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -238,3 +238,3 @@ Nodeunit | ||
bin/nodeunit.json for current available options. | ||
* __-t testName__ - run specifc test only. | ||
* __-t testName__ - run specific test only. | ||
* __-f fullTestName__ - run specific test only. fullTestName is built so: "outerGroup - .. - innerGroup - testName". | ||
@@ -241,0 +241,0 @@ * __--version__ or __-v__ - report nodeunit version |
@@ -6,2 +6,3 @@ var exec = require('child_process').exec, | ||
var testfile_fullpath = path.resolve(__dirname, './fixtures/example_test.js'); | ||
var fixtures_path = path.resolve(__dirname, './fixtures'); | ||
@@ -18,1 +19,23 @@ exports['run test suite using absolute path'] = function (test) { | ||
}; | ||
exports['runs only top-level suites without recursive flag'] = function (test) { | ||
exec(bin + ' ' + fixtures_path, function (err, stdout, stderr) { | ||
if (err) { | ||
return test.done(err); | ||
} | ||
test.ok(/example test/.test(stdout)); | ||
test.ok(!/example test sub/.test(stdout)); | ||
test.done(); | ||
}); | ||
}; | ||
exports['runs top + nested suites with recursive flag'] = function (test) { | ||
exec(bin + ' ' + fixtures_path + ' -r', function (err, stdout, stderr) { | ||
if (err) { | ||
return test.done(err); | ||
} | ||
test.ok(/example test/.test(stdout)); | ||
test.ok(/example test sub/.test(stdout)); | ||
test.done(); | ||
}); | ||
}; |
@@ -22,3 +22,3 @@ var assert = require('assert'), | ||
exports.testRunFiles = setup(function (test) { | ||
test.expect(28); | ||
test.expect(33); | ||
var runModule_copy = nodeunit.runModule; | ||
@@ -47,3 +47,3 @@ | ||
test.equals(assertions.failures(), 0, 'failures'); | ||
test.equals(assertions.length, 4, 'length'); | ||
test.equals(assertions.length, 5, 'length'); | ||
test.ok(typeof assertions.duration === "number"); | ||
@@ -60,3 +60,3 @@ | ||
test.ok(called_with('mock_module4'), 'mock_module4 ran'); | ||
test.equals(runModule_calls.length, 4); | ||
test.equals(runModule_calls.length, 5); | ||
@@ -63,0 +63,0 @@ nodeunit.runModule = runModule_copy; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
793480
85
8063