Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix uncaught exception handler, make istanbul default and add CLI opt…

…ion for --init
  • Loading branch information...
commit 54f3d1c39b01c0297d5fb1aac7e256bda75ecc90 1 parent 9c59da6
@gotwarlost authored
View
20 lib/cli.js
@@ -38,7 +38,8 @@ var path = require('path'),
defaultTestExcludes = [],
defaultCoverageIncludes = [ '**/*.js' ],
defaultCoverageExcludes = [ 'test/**/*.js', 'tests/**/*.js', '**/.*', '**/node_modules/**' ],
- cacheBuster = 1;
+ cacheBuster = 1,
+ util = require('util');
/**
* Command-line entry point to the test runner, also exposed as a library.
@@ -75,10 +76,11 @@ function getDefaults() {
return {
root: process.cwd(),
tmp: '/tmp',
+ init: null,
include: defaultTestIncludes,
exclude: defaultTestExcludes,
coverage: false,
- istanbul: false,
+ istanbul: true,
covInclude: defaultCoverageIncludes,
covExclude: defaultCoverageExcludes,
resultsFile: 'results',
@@ -111,6 +113,7 @@ function usage() {
{
group: 'Tests and results',
values: [
+ { name: 'init', arg: 'init-file', desc: 'initialize fixtures using async `initialize` function loaded from `init-file`' },
{ name: 'include', arg: 'pattern', desc: 'include file patterns for test files', defaultValue: '[' + defs.include.join(', ') + ']' },
{ name: 'exclude', arg: 'pattern',desc: 'exclude file patterns for test files', defaultValue: '[' + (defs.exclude.join(', ') || ' empty ') + ']' },
{ name: 'save-results', desc: 'save results to disk' },
@@ -186,6 +189,7 @@ function getOptions(args) {
help: Boolean,
colors: Boolean,
+ init: path,
include: [ Array, String ],
exclude: [ Array, String ],
@@ -304,7 +308,7 @@ function runConfig(config, callback) {
}
try {
files = files.map(function (f) { return path.resolve(root, f); });
- runner.runTests(files, realCallback);
+ runner.runTests(files, config.init, realCallback);
} catch (ex) {
console.error('runTests returned an error');
return realCallback(ex);
@@ -350,13 +354,9 @@ function main() {
process.once('uncaughtException', function (ex) {
exitCode = 2;
- console.error('Uncaught exception!');
+ util.error('Uncaught exception!');
log.logError(ex);
- //ensure process exits eventually with some time to flush buffers
- //even when there are outstanding events in the event loop
- setTimeout(function () {
- process.exit(exitCode);
- }, 1000);
+ process.exit(exitCode);
});
run(process.argv.slice(2), function (err, data) {
@@ -368,7 +368,7 @@ function main() {
if (data.ok) {
exitCode = 0;
} else {
- console.error(data.error);
+ util.error(data.error);
exitCode = 1;
}
});
View
3  lib/util/log.js
@@ -26,6 +26,7 @@
*/
var colors = require('colors'),
+ util = require('util'),
verbose = false,
colorLog = false;
@@ -36,7 +37,7 @@ function out(str) {
function err(str) {
if (colorLog) { str = str.bold; str = str.red; }
- console.error(str);
+ util.error(str);
}
/**
* @class Log
View
2  package.json
@@ -2,7 +2,7 @@
"name":"ytestrunner",
"author":"Krishnan Anantheswaran <kananthmail-github@yahoo.com>",
"description":"Run YUI tests for node packages using npm test with support for saving test results, coverage and more. Supports YUITest as well as YUI3 style tests.",
- "version":"0.2.5",
+ "version":"0.3.0",
"repository":{
"type":"git",
"url":"git://github.com/gotwarlost/ytestrunner.git"
View
2  test/common/common-functional.js
@@ -26,7 +26,7 @@ module.exports = {
});
},
"with coverage turned on": {
- setUp: function (cb) { args.push.apply(args, ['--coverage=true', '--verbose=true']); cb(); },
+ setUp: function (cb) { args.push.apply(args, ['--coverage=true', '--verbose=true', '--istanbul=false']); cb(); },
"should calculate coverage": function (test) {
watcher.run(args, function (err) {
test.ok(!err, "should work without errors");
Please sign in to comment.
Something went wrong with that request. Please try again.