Comparing version 0.5.3 to 0.5.4
@@ -34,2 +34,12 @@ /*! | ||
var _copy = function(obj){ | ||
var nobj = Object(); | ||
var keys = _keys(obj); | ||
for (var i = 0; i < keys.length; i++){ | ||
nobj[keys[i]] = obj[keys[i]]; | ||
} | ||
return nobj; | ||
} | ||
/** | ||
@@ -91,3 +101,8 @@ * Runs a test function (fn) from a loaded module. After the test function | ||
if (typeof prop === 'function') { | ||
exports.runTest(_name, suite[k], opt, cb); | ||
if (!opt.testspec || _name.indexOf(opt.testspec) != -1){ | ||
if (opt.moduleStart) | ||
opt.moduleStart(); | ||
exports.runTest(_name, suite[k], opt, cb); | ||
} else | ||
return cb(); | ||
} | ||
@@ -111,8 +126,17 @@ else { | ||
exports.runModule = function (name, mod, opt, callback) { | ||
var options = types.options(opt); | ||
var options = _copy(types.options(opt)); | ||
options.moduleStart(name); | ||
var _run = false; | ||
var _moduleStart = options.moduleStart; | ||
function run_once(){ | ||
if (!_run){ | ||
_run = true; | ||
_moduleStart(name); | ||
} | ||
} | ||
options.moduleStart = run_once; | ||
var start = new Date().getTime(); | ||
exports.runSuite(null, mod, opt, function (err, a_list) { | ||
exports.runSuite(null, mod, options, function (err, a_list) { | ||
var end = new Date().getTime(); | ||
@@ -119,0 +143,0 @@ var assertion_list = types.assertionList(a_list, end - start); |
@@ -16,2 +16,3 @@ /*! | ||
reporters = require('./reporters'), | ||
assert = require('./assert'), | ||
path = require('path'); | ||
@@ -27,2 +28,3 @@ | ||
exports.reporters = reporters; | ||
exports.assert = assert; | ||
@@ -29,0 +31,0 @@ // backwards compatibility |
@@ -14,3 +14,2 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
track = require('../track'), | ||
@@ -63,4 +62,4 @@ path = require('path'); | ||
if (tracker.unfinished()) { | ||
sys.puts(''); | ||
sys.puts(error(bold( | ||
console.log(''); | ||
console.log(error(bold( | ||
'FAILURES: Undone tests (or their setups/teardowns): ' | ||
@@ -70,6 +69,6 @@ ))); | ||
for (var i = 0; i < names.length; i += 1) { | ||
sys.puts('- ' + names[i]); | ||
console.log('- ' + names[i]); | ||
} | ||
sys.puts(''); | ||
sys.puts('To fix this, make sure all tests call test.done()'); | ||
console.log(''); | ||
console.log('To fix this, make sure all tests call test.done()'); | ||
process.reallyExit(tracker.unfinished()); | ||
@@ -80,4 +79,5 @@ } | ||
nodeunit.runFiles(paths, { | ||
testspec: options.testspec, | ||
moduleStart: function (name) { | ||
sys.puts('\n' + bold(name)); | ||
console.log('\n' + bold(name)); | ||
}, | ||
@@ -88,6 +88,6 @@ testDone: function (name, assertions) { | ||
if (!assertions.failures()) { | ||
sys.puts('✔ ' + name); | ||
console.log('✔ ' + name); | ||
} | ||
else { | ||
sys.puts(error('✖ ' + name) + '\n'); | ||
console.log(error('✖ ' + name) + '\n'); | ||
assertions.forEach(function (a) { | ||
@@ -97,3 +97,3 @@ if (a.failed()) { | ||
if (a.error instanceof AssertionError && a.message) { | ||
sys.puts( | ||
console.log( | ||
'Assertion Message: ' + | ||
@@ -103,3 +103,3 @@ assertion_message(a.message) | ||
} | ||
sys.puts(a.error.stack + '\n'); | ||
console.log(a.error.stack + '\n'); | ||
} | ||
@@ -109,7 +109,7 @@ }); | ||
}, | ||
done: function (assertions) { | ||
var end = new Date().getTime(); | ||
done: function (assertions, end) { | ||
var end = end || new Date().getTime(); | ||
var duration = end - start; | ||
if (assertions.failures()) { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(error('FAILURES: ')) + assertions.failures() + | ||
@@ -121,15 +121,7 @@ '/' + assertions.length + ' assertions failed (' + | ||
else { | ||
sys.puts( | ||
'\n' + bold(ok('OK: ')) + assertions.length + | ||
' assertions (' + assertions.duration + 'ms)' | ||
console.log( | ||
'\n' + bold(ok('OK: ')) + assertions.length + | ||
' assertions (' + assertions.duration + 'ms)' | ||
); | ||
} | ||
// alexgorbatchev 2010-11-10 :: should be able to flush stdout | ||
// here, but doesn't seem to work, instead delay the exit to give | ||
// enough to time flush. | ||
// process.stdout.flush() | ||
// process.stdout.end() | ||
setTimeout(function () { | ||
process.reallyExit(assertions.failures()); | ||
}, 10); | ||
}, | ||
@@ -136,0 +128,0 @@ testStart: function(name) { |
@@ -14,3 +14,2 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
path = require('path'), | ||
@@ -39,11 +38,11 @@ AssertionError = require('assert').AssertionError; | ||
sys.puts('<html>'); | ||
sys.puts('<head>'); | ||
sys.puts('<title></title>'); | ||
sys.puts('<style type="text/css">'); | ||
sys.puts('body { font: 12px Helvetica Neue }'); | ||
sys.puts('h2 { margin:0 ; padding:0 }'); | ||
sys.puts('pre { font: 11px Andale Mono; margin-left: 1em; padding-left: 1em; margin-top:0; font-size:smaller;}'); | ||
sys.puts('.assertion_message { margin-left: 1em; }'); | ||
sys.puts(' ol {' + | ||
console.log('<html>'); | ||
console.log('<head>'); | ||
console.log('<title></title>'); | ||
console.log('<style type="text/css">'); | ||
console.log('body { font: 12px Helvetica Neue }'); | ||
console.log('h2 { margin:0 ; padding:0 }'); | ||
console.log('pre { font: 11px Andale Mono; margin-left: 1em; padding-left: 1em; margin-top:0; font-size:smaller;}'); | ||
console.log('.assertion_message { margin-left: 1em; }'); | ||
console.log(' ol {' + | ||
' list-style: none;' + | ||
@@ -54,18 +53,19 @@ ' margin-left: 1em;' + | ||
'}'); | ||
sys.puts(' ol li.pass:before { content: "\\2714 \\0020"; }'); | ||
sys.puts(' ol li.fail:before { content: "\\2716 \\0020"; }'); | ||
sys.puts('</style>'); | ||
sys.puts('</head>'); | ||
sys.puts('<body>'); | ||
console.log(' ol li.pass:before { content: "\\2714 \\0020"; }'); | ||
console.log(' ol li.fail:before { content: "\\2716 \\0020"; }'); | ||
console.log('</style>'); | ||
console.log('</head>'); | ||
console.log('<body>'); | ||
nodeunit.runFiles(paths, { | ||
testspec: options.testspec, | ||
moduleStart: function (name) { | ||
sys.puts('<h2>' + name + '</h2>'); | ||
sys.puts('<ol>'); | ||
console.log('<h2>' + name + '</h2>'); | ||
console.log('<ol>'); | ||
}, | ||
testDone: function (name, assertions) { | ||
if (!assertions.failures()) { | ||
sys.puts('<li class="pass">' + name + '</li>'); | ||
console.log('<li class="pass">' + name + '</li>'); | ||
} | ||
else { | ||
sys.puts('<li class="fail">' + name); | ||
console.log('<li class="fail">' + name); | ||
assertions.forEach(function (a) { | ||
@@ -75,16 +75,16 @@ if (a.failed()) { | ||
if (a.error instanceof AssertionError && a.message) { | ||
sys.puts('<div class="assertion_message">' + | ||
console.log('<div class="assertion_message">' + | ||
'Assertion Message: ' + a.message + | ||
'</div>'); | ||
} | ||
sys.puts('<pre>'); | ||
sys.puts(a.error.stack); | ||
sys.puts('</pre>'); | ||
console.log('<pre>'); | ||
console.log(a.error.stack); | ||
console.log('</pre>'); | ||
} | ||
}); | ||
sys.puts('</li>'); | ||
console.log('</li>'); | ||
} | ||
}, | ||
moduleDone: function () { | ||
sys.puts('</ol>'); | ||
console.log('</ol>'); | ||
}, | ||
@@ -95,3 +95,3 @@ done: function (assertions) { | ||
if (assertions.failures()) { | ||
sys.puts( | ||
console.log( | ||
'<h3>FAILURES: ' + assertions.failures() + | ||
@@ -103,3 +103,3 @@ '/' + assertions.length + ' assertions failed (' + | ||
else { | ||
sys.puts( | ||
console.log( | ||
'<h3>OK: ' + assertions.length + | ||
@@ -109,8 +109,3 @@ ' assertions (' + assertions.duration + 'ms)</h3>' | ||
} | ||
sys.puts('</body>'); | ||
// should be able to flush stdout here, but doesn't seem to work, | ||
// instead delay the exit to give enough to time flush. | ||
setTimeout(function () { | ||
process.reallyExit(assertions.failures()); | ||
}, 10); | ||
console.log('</body>'); | ||
} | ||
@@ -117,0 +112,0 @@ }); |
@@ -14,3 +14,2 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
path = require('path'), | ||
@@ -106,2 +105,3 @@ async = require('../../deps/async'), | ||
nodeunit.runFiles(paths, { | ||
testspec: opts.testspec, | ||
moduleStart: function (name) { | ||
@@ -159,3 +159,3 @@ curModule = { | ||
); | ||
sys.puts('Writing ' + filename); | ||
console.log('Writing ' + filename); | ||
fs.writeFile(filename, rendered, cb); | ||
@@ -166,3 +166,3 @@ }, | ||
else if (assertions.failures()) { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(error('FAILURES: ')) + | ||
@@ -175,3 +175,3 @@ assertions.failures() + '/' + | ||
else { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(ok('OK: ')) + assertions.length + | ||
@@ -181,5 +181,2 @@ ' assertions (' + assertions.duration + 'ms)' | ||
} | ||
setTimeout(function () { | ||
process.reallyExit(assertions.failures()); | ||
}, 10); | ||
}); | ||
@@ -186,0 +183,0 @@ |
@@ -14,3 +14,2 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
path = require('path'), | ||
@@ -61,7 +60,8 @@ AssertionError = require('assert').AssertionError; | ||
nodeunit.runFiles(paths, { | ||
testspec: options.testspec, | ||
moduleStart: function (name) { | ||
sys.print(bold(name) + ': '); | ||
process.stdout.write(bold(name) + ': '); | ||
}, | ||
moduleDone: function (name, assertions) { | ||
sys.puts(''); | ||
console.log(''); | ||
if (assertions.failures()) { | ||
@@ -72,3 +72,3 @@ assertions.forEach(function (a) { | ||
if (a.error instanceof AssertionError && a.message) { | ||
sys.puts( | ||
console.log( | ||
'Assertion in test ' + bold(a.testname) + ': ' + | ||
@@ -78,3 +78,3 @@ magenta(a.message) | ||
} | ||
sys.puts(a.error.stack + '\n'); | ||
console.log(a.error.stack + '\n'); | ||
} | ||
@@ -89,6 +89,6 @@ }); | ||
if (!assertions.failures()) { | ||
sys.print('.'); | ||
process.stdout.write('.'); | ||
} | ||
else { | ||
sys.print(red('F')); | ||
process.stdout.write(red('F')); | ||
assertions.forEach(function (assertion) { | ||
@@ -103,3 +103,3 @@ assertion.testname = name; | ||
if (assertions.failures()) { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(red('FAILURES: ')) + assertions.failures() + | ||
@@ -111,3 +111,3 @@ '/' + assertions.length + ' assertions failed (' + | ||
else { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(green('OK: ')) + assertions.length + | ||
@@ -117,9 +117,4 @@ ' assertions (' + assertions.duration + 'ms)' | ||
} | ||
// should be able to flush stdout here, but doesn't seem to work, | ||
// instead delay the exit to give enough to time flush. | ||
setTimeout(function () { | ||
process.reallyExit(assertions.failures()); | ||
}, 10); | ||
} | ||
}); | ||
}; |
@@ -14,3 +14,2 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
path = require('path'), | ||
@@ -61,8 +60,9 @@ AssertionError = require('assert').AssertionError; | ||
nodeunit.runFiles(paths, { | ||
testspec: options.testspec, | ||
moduleStart: function (name) { | ||
sys.puts('\n' + bold(name)); | ||
console.log('\n' + bold(name)); | ||
}, | ||
testDone: function (name, assertions) { | ||
if (assertions.failures()) { | ||
sys.puts(error('✖ ' + name) + '\n'); | ||
console.log(error('✖ ' + name) + '\n'); | ||
assertions.forEach(function (a) { | ||
@@ -72,7 +72,7 @@ if (a.failed()) { | ||
if (a.error instanceof AssertionError && a.message) { | ||
sys.puts( | ||
console.log( | ||
'Assertion Message: ' + assertion_message(a.message) | ||
); | ||
} | ||
sys.puts(a.error.stack + '\n'); | ||
console.log(a.error.stack + '\n'); | ||
} | ||
@@ -84,6 +84,6 @@ }); | ||
if (!assertions.failures()) { | ||
sys.puts('✔ all tests passed'); | ||
console.log('✔ all tests passed'); | ||
} | ||
else { | ||
sys.puts(error('✖ some tests failed')); | ||
console.log(error('✖ some tests failed')); | ||
} | ||
@@ -95,3 +95,3 @@ }, | ||
if (assertions.failures()) { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(error('FAILURES: ')) + assertions.failures() + | ||
@@ -103,3 +103,3 @@ '/' + assertions.length + ' assertions failed (' + | ||
else { | ||
sys.puts( | ||
console.log( | ||
'\n' + bold(ok('OK: ')) + assertions.length + | ||
@@ -109,9 +109,4 @@ ' assertions (' + assertions.duration + 'ms)' | ||
} | ||
// should be able to flush stdout here, but doesn't seem to work, | ||
// instead delay the exit to give enough to time flush. | ||
setTimeout(function () { | ||
process.reallyExit(assertions.failures()); | ||
}, 10); | ||
} | ||
}); | ||
}; |
@@ -6,5 +6,3 @@ /*! | ||
var sys = require('sys'); | ||
exports.createTracker = function (on_exit) { | ||
@@ -43,7 +41,7 @@ var names = {}; | ||
if (tracker.unfinished()) { | ||
sys.puts(''); | ||
sys.puts('Undone tests (or their setups/teardowns): '); | ||
console.log(''); | ||
console.log('Undone tests (or their setups/teardowns): '); | ||
var names = tracker.names(); | ||
for (var i = 0; i < names.length; i += 1) { | ||
sys.puts(names[i]); | ||
console.log(names[i]); | ||
} | ||
@@ -50,0 +48,0 @@ process.reallyExit(tracker.unfinished()); |
@@ -13,3 +13,3 @@ /*! | ||
fs = require('fs'), | ||
sys = require('sys'), | ||
util = require('util'), | ||
Script = process.binding('evals').Script, | ||
@@ -194,4 +194,4 @@ http = require('http'); | ||
// alexgorbatchev 2010-10-22 :: Added a bit of depth to inspection | ||
var actual = sys.inspect(e.actual, false, 10).replace(/\n$/, ''); | ||
var expected = sys.inspect(e.expected, false, 10).replace(/\n$/, ''); | ||
var actual = util.inspect(e.actual, false, 10).replace(/\n$/, ''); | ||
var expected = util.inspect(e.expected, false, 10).replace(/\n$/, ''); | ||
var multiline = ( | ||
@@ -198,0 +198,0 @@ actual.indexOf('\n') !== -1 || |
@@ -39,4 +39,7 @@ { "name": "nodeunit" | ||
} | ||
, { "name": "Elijah Insua <tmpvar@gmail.com>", | ||
"web": "http://tmpvar.com" | ||
} | ||
] | ||
, "version": "0.5.1" | ||
, "version": "0.5.3" | ||
, "repository" : | ||
@@ -43,0 +46,0 @@ { "type" : "git" |
@@ -43,3 +43,3 @@ { "name": "nodeunit" | ||
] | ||
, "version": "0.5.3" | ||
, "version": "0.5.4" | ||
, "repository" : | ||
@@ -46,0 +46,0 @@ { "type" : "git" |
@@ -297,8 +297,6 @@ Nodeunit | ||
you'll want to create a script that runs the tests for your project with the | ||
correct require paths set up. Here's an example test script, with a deps | ||
directory containing the projects dependencies: | ||
correct require paths set up. Here's an example test script, that assumes you | ||
have nodeunit in a suitably located node_modules directory. | ||
#!/usr/bin/env node | ||
require.paths.unshift(__dirname + '/deps'); | ||
var reporter = require('nodeunit').reporters.default; | ||
@@ -312,6 +310,6 @@ reporter.run(['test']); | ||
git submodule add git://github.com/caolan/nodeunit.git deps/nodeunit | ||
git submodule add git://github.com/caolan/nodeunit.git node_modules/nodeunit | ||
This will add nodeunit to the deps folder of your project. Now, when cloning | ||
the repository, nodeunit can be downloaded by doing the following: | ||
This will add nodeunit to the node_modules folder of your project. Now, when | ||
cloning the repository, nodeunit can be downloaded by doing the following: | ||
@@ -325,5 +323,2 @@ git submodule init | ||
#!/usr/bin/env node | ||
require.paths.unshift(__dirname + '/deps'); | ||
try { | ||
@@ -422,3 +417,3 @@ var reporter = require('nodeunit').reporters.default; | ||
To run the nodeunit tests do: | ||
make test | ||
@@ -436,2 +431,1 @@ | ||
we're following a consistent coding style. | ||
@@ -10,8 +10,7 @@ var assert = require('assert'), | ||
process.chdir(__dirname); | ||
require.paths.push(__dirname); | ||
var env = { | ||
mock_module1: require('./fixtures/mock_module1'), | ||
mock_module2: require('./fixtures/mock_module2'), | ||
mock_module3: require('./fixtures/dir/mock_module3'), | ||
mock_module4: require('./fixtures/dir/mock_module4') | ||
mock_module1: require(__dirname + '/fixtures/mock_module1'), | ||
mock_module2: require(__dirname + '/fixtures/mock_module2'), | ||
mock_module3: require(__dirname + '/fixtures/dir/mock_module3'), | ||
mock_module4: require(__dirname + '/fixtures/dir/mock_module4') | ||
}; | ||
@@ -78,3 +77,5 @@ fn.call(env, test); | ||
nodeunit.runFiles( | ||
['fixtures/mock_module1.js', 'fixtures/mock_module2.js', 'fixtures/dir'], | ||
[__dirname + '/fixtures/mock_module1.js', | ||
__dirname + '/fixtures/mock_module2.js', | ||
__dirname + '/fixtures/dir'], | ||
opts | ||
@@ -152,5 +153,5 @@ ); | ||
process.chdir(__dirname); | ||
require.paths.push(__dirname); | ||
var env = { | ||
mock_coffee_module: require('./fixtures/coffee/mock_coffee_module') | ||
mock_coffee_module: require(__dirname + | ||
'/fixtures/coffee/mock_coffee_module') | ||
}; | ||
@@ -212,3 +213,3 @@ | ||
nodeunit.runFiles( | ||
['fixtures/coffee/mock_coffee_module.coffee'], | ||
[__dirname + 'fixtures/coffee/mock_coffee_module.coffee'], | ||
opts | ||
@@ -215,0 +216,0 @@ ); |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
371059
78
8076
427
24