Skip to content

Commit

Permalink
nested reporter: fixing nodelint failures (with white set to false fo…
Browse files Browse the repository at this point in the history
…r strict whitespace)
  • Loading branch information
BryanDonovan committed Oct 29, 2011
1 parent de9c0e3 commit 0125691
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
38 changes: 20 additions & 18 deletions lib/reporters/nested.js
Expand Up @@ -34,7 +34,8 @@ exports.run = function (files, options) {
if (!options) {
// load default options
var content = fs.readFileSync(
__dirname + '/../../bin/nodeunit.json', 'utf8'
__dirname + '/../../bin/nodeunit.json',
'utf8'
);
options = JSON.parse(content);
}
Expand All @@ -57,13 +58,14 @@ exports.run = function (files, options) {
return path.join(process.cwd(), p);
});
var tracker = track.createTracker(function (tracker) {
var i, names;
if (tracker.unfinished()) {
console.log('');
console.log(error(bold(
'FAILURES: Undone tests (or their setups/teardowns): '
)));
var names = tracker.names();
for (var i = 0; i < names.length; i += 1) {
names = tracker.names();
for (i = 0; i < names.length; i += 1) {
console.log('- ' + names[i]);
}
console.log('');
Expand All @@ -76,15 +78,16 @@ exports.run = function (files, options) {
// i.e., whether this part has been printed yet.
tracker.already_printed = {};

tracker.print_status = function(status, name_arr) {
tracker.print_status = function (status, name_arr) {
var txt = '';
var space = " ";
for (var i = 0; i < name_arr.length; i++) {
var part = name_arr.slice(0, i+1).join(",");
var part, i, k;
for (i = 0; i < name_arr.length; i++) {
part = name_arr.slice(0, i + 1).join(",");
// Only print the part if it hasn't already been printed.
if (!tracker.already_printed[part]) {
// Indent once for each nested level
for (var k = 0; k < i; k++) {
for (k = 0; k < i; k++) {
txt += space;
}
if (i === name_arr.length - 1) {
Expand All @@ -95,7 +98,8 @@ exports.run = function (files, options) {
txt += bold(error(name_arr[i] + " (fail) ✖ "));
}
} else {
// This is a testCase, just print the testCase name and a newline.
// This is a testCase, just print the testCase name
// and a newline.
txt += name_arr[i];
txt += "\n";
}
Expand All @@ -115,16 +119,15 @@ exports.run = function (files, options) {

if (!assertions.failures()) {
tracker.print_status('pass', name);
}
else {
} else {
tracker.print_status('fail', name);
assertions.forEach(function (a) {
if (a.failed()) {
a = utils.betterErrors(a);
if (a.error instanceof AssertionError && a.message) {
console.log(
'Assertion Message: ' +
assertion_message(a.message)
assertion_message(a.message)
);
}
console.log(a.error.stack + '\n');
Expand All @@ -138,18 +141,17 @@ exports.run = function (files, options) {
if (assertions.failures()) {
console.log(
'\n' + bold(error('FAILURES: ')) + assertions.failures() +
'/' + assertions.length + ' assertions failed (' +
assertions.duration + 'ms)'
'/' + assertions.length + ' assertions failed (' +
assertions.duration + 'ms)'
);
}
else {
} else {
console.log(
'\n' + bold(ok('OK: ')) + assertions.length +
' assertions (' + assertions.duration + 'ms)'
'\n' + bold(ok('OK: ')) + assertions.length +
' assertions (' + assertions.duration + 'ms)'
);
}
},
testStart: function(name) {
testStart: function (name) {
tracker.put(name);
}
});
Expand Down
5 changes: 4 additions & 1 deletion nodelint.cfg
@@ -1,4 +1,7 @@
//See: http://www.jslint.com/lint.html#options
var options = {
//white: false, // if false, strict whitespace rules should be enforced.
indent: 4,
onevar: false
onevar: false,
vars: true // allow multiple var statement per function.
};

0 comments on commit 0125691

Please sign in to comment.