From 1d65d56a927d4f6c5ca35297cd5f2ca0e628594a Mon Sep 17 00:00:00 2001 From: "Davis W. Frank" Date: Mon, 16 May 2011 08:08:12 -0700 Subject: [PATCH 1/2] TrivialConsoleReporter refactor & fixes. No longer limitied to 50 columns of dots. --- lib/jasmine.css | 2 +- spec/node_suite.js | 2 +- spec/suites/TrivialConsoleReporterSpec.js | 781 +++++++++++----------- src/console/TrivialConsoleReporter.js | 6 +- 4 files changed, 407 insertions(+), 384 deletions(-) diff --git a/lib/jasmine.css b/lib/jasmine.css index 6583fe7..5051114 100644 --- a/lib/jasmine.css +++ b/lib/jasmine.css @@ -163,4 +163,4 @@ body { display: block; margin: 5px 0; padding: 2px 0 2px 10px; -} +} \ No newline at end of file diff --git a/spec/node_suite.js b/spec/node_suite.js index ffa824e..9d7f7bc 100644 --- a/spec/node_suite.js +++ b/spec/node_suite.js @@ -43,7 +43,7 @@ jasmine.executeSpecs = function(specs, done){ } var jasmineEnv = jasmine.getEnv(); - jasmineEnv.reporter = new jasmine.TrivialConsoleReporter(sys.print, done) + jasmineEnv.reporter = new jasmine.TrivialConsoleReporter(sys.print, done); jasmineEnv.execute(); }; diff --git a/spec/suites/TrivialConsoleReporterSpec.js b/spec/suites/TrivialConsoleReporterSpec.js index 37e81aa..80a77bb 100644 --- a/spec/suites/TrivialConsoleReporterSpec.js +++ b/spec/suites/TrivialConsoleReporterSpec.js @@ -1,429 +1,452 @@ describe("TrivialConsoleReporter", function() { - - //keep these literal. otherwise the test loses value as a test. - function green(str) { return '\033[32m' + str + '\033[0m'; } - function red(str) { return '\033[31m' + str + '\033[0m'; } - function yellow(str) { return '\033[33m' + str + '\033[0m'; } - - function prefixGreen(str) { return '\033[32m' + str; } - function prefixRed(str) { return '\033[31m' + str; } - + function green(str) { + return '\033[32m' + str + '\033[0m'; + } + + function red(str) { + return '\033[31m' + str + '\033[0m'; + } + + function yellow(str) { + return '\033[33m' + str + '\033[0m'; + } + + function prefixGreen(str) { + return '\033[32m' + str; + } + + function prefixRed(str) { + return '\033[31m' + str; + } + var newline = "\n"; - - var passingSpec = { results: function(){ return {passed: function(){return true;}}; } }, - failingSpec = { results: function(){ return {passed: function(){return false;}}; } }, - skippedSpec = { results: function(){ return {skipped: true}; } }, - passingRun = { results: function(){ return {failedCount: 0, items_: [null, null, null]}; } }, - failingRun = { results: function(){ return {failedCount: 7, items_: [null, null, null]}; } }; - - function repeatedlyInvoke(f, times) { for(var i=0; i Date: Mon, 16 May 2011 18:28:46 -0700 Subject: [PATCH 2/2] TrivialConsoleReporter now reports the correct number of specs that were executed. TCR is still very heavily mocked instead of using testing an actual Jasmine environment. But now at least the numbers are correct. --- spec/node_suite.js | 85 ++++----- spec/suites/TrivialConsoleReporterSpec.js | 84 ++++++--- src/console/TrivialConsoleReporter.js | 211 +++++++++++++--------- 3 files changed, 229 insertions(+), 151 deletions(-) diff --git a/spec/node_suite.js b/spec/node_suite.js index 9d7f7bc..1e61804 100644 --- a/spec/node_suite.js +++ b/spec/node_suite.js @@ -6,24 +6,26 @@ var path = require('path'); // undefined = "diz be undefined yo"; var jasmineGlobals = require("../src/base"); -for(var k in jasmineGlobals) {global[k] = jasmineGlobals[k];} +for (var k in jasmineGlobals) { + global[k] = jasmineGlobals[k]; +} //load jasmine src files based on the order in runner.html var srcFilesInProperRequireOrder = []; var runnerHtmlLines = fs.readFileSync("spec/runner.html", "utf8").split("\n"); var srcFileLines = []; -for (var i=0; i 0 && spec.description) suiteResult.failedSpecResults.push(spec); }); - + this.suiteResults.push(suiteResult); }; - + function eachSpecFailure(suiteResults, callback) { - for(var i=0; i