finalize the runner, time to merge?

This commit is contained in:
John Bintz 2011-11-05 14:19:41 -04:00
parent 3a559fb0d5
commit 5ca065728d
6 changed files with 30 additions and 13 deletions

View File

@ -14,6 +14,7 @@ using namespace std;
Runner::Runner() : QObject() Runner::Runner() : QObject()
, runs(0) , runs(0)
, hasErrors(false) , hasErrors(false)
, _hasSpecFailure(false)
, usedConsole(false) , usedConsole(false)
, isFinished(false) , isFinished(false)
, useColors(false) , useColors(false)
@ -99,6 +100,10 @@ void Runner::hasError() {
hasErrors = true; hasErrors = true;
} }
void Runner::hasSpecFailure() {
_hasSpecFailure = true;
}
void Runner::reportFile(const QString &file) { void Runner::reportFile(const QString &file) {
reportFileName = file; reportFileName = file;
} }
@ -144,7 +149,7 @@ void Runner::timerEvent() {
} }
int exitCode = 0; int exitCode = 0;
if (hasErrors) { if (_hasSpecFailure || hasErrors) {
exitCode = 1; exitCode = 1;
} else { } else {
if (usedConsole) { if (usedConsole) {

View File

@ -29,6 +29,7 @@ class Runner: public QObject {
void timerDone(); void timerDone();
void hasUsedConsole(); void hasUsedConsole();
void hasError(); void hasError();
void hasSpecFailure();
void print(const QString &fh, const QString &content); void print(const QString &fh, const QString &content);
void finishSuite(); void finishSuite();
@ -43,6 +44,7 @@ class Runner: public QObject {
QTimer ticker; QTimer ticker;
int runs; int runs;
bool hasErrors; bool hasErrors;
bool _hasSpecFailure;
bool usedConsole; bool usedConsole;
bool isFinished; bool isFinished;
bool useColors; bool useColors;

View File

@ -10,9 +10,6 @@ class jasmine.HeadlessConsoleReporter
reportRunnerResults: (runner) -> reportRunnerResults: (runner) ->
return if this.hasError() return if this.hasError()
if window.JHW
window.onbeforeunload = null
runtime = (new Date() - @startTime) / 1000.0 runtime = (new Date() - @startTime) / 1000.0
JHW.stdout.print("\n") JHW.stdout.print("\n")
@ -23,12 +20,16 @@ class jasmine.HeadlessConsoleReporter
JHW.stdout.puts("PASS: #{resultLine}".foreground('green')) JHW.stdout.puts("PASS: #{resultLine}".foreground('green'))
else else
JHW.stdout.puts("FAIL: #{resultLine}".foreground('red')) JHW.stdout.puts("FAIL: #{resultLine}".foreground('red'))
JHW.hasSpecFailure()
output = "TOTAL||#{@length}||#{@failedCount}||#{runtime}||#{if JHW._hasErrors then "T" else "F"}" output = "TOTAL||#{@length}||#{@failedCount}||#{runtime}||#{if JHW._hasErrors then "T" else "F"}"
JHW.report.puts(output) JHW.report.puts(output)
result.print() for result in @results result.print() for result in @results
if window.JHW
window.onbeforeunload = null
JHW.finishSuite() JHW.finishSuite()
reportRunnerStarting: (runner) -> reportRunnerStarting: (runner) ->
@ -47,7 +48,6 @@ class jasmine.HeadlessConsoleReporter
else else
JHW.stdout.print('F'.foreground('red')) JHW.stdout.print('F'.foreground('red'))
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation()) JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
JHW.hasError()
@failedCount++ @failedCount++
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()) failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())

View File

@ -27,9 +27,15 @@ if window.JHW
data data
window.onbeforeunload = (e) -> window.onbeforeunload = (e) ->
JHW.stderr.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.') e = e || window.event
JHW.hasError() JHW.hasError()
return false JHW.stdout.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.')
if e
e.returnValue = 'string'
return 'string'
window.confirm = (message) -> window.confirm = (message) ->
JHW.stderr.puts("#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.") JHW.stderr.puts("#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.")

View File

@ -14,9 +14,6 @@
if (this.hasError()) { if (this.hasError()) {
return; return;
} }
if (window.JHW) {
window.onbeforeunload = null;
}
runtime = (new Date() - this.startTime) / 1000.0; runtime = (new Date() - this.startTime) / 1000.0;
JHW.stdout.print("\n"); JHW.stdout.print("\n");
resultLine = this._formatResultLine(runtime); resultLine = this._formatResultLine(runtime);
@ -24,6 +21,7 @@
JHW.stdout.puts(("PASS: " + resultLine).foreground('green')); JHW.stdout.puts(("PASS: " + resultLine).foreground('green'));
} else { } else {
JHW.stdout.puts(("FAIL: " + resultLine).foreground('red')); JHW.stdout.puts(("FAIL: " + resultLine).foreground('red'));
JHW.hasSpecFailure();
} }
output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + runtime + "||" + (JHW._hasErrors ? "T" : "F"); output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + runtime + "||" + (JHW._hasErrors ? "T" : "F");
JHW.report.puts(output); JHW.report.puts(output);
@ -32,6 +30,9 @@
result = _ref[_i]; result = _ref[_i];
result.print(); result.print();
} }
if (window.JHW) {
window.onbeforeunload = null;
}
return JHW.finishSuite(); return JHW.finishSuite();
}; };
HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) { HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) {
@ -51,7 +52,6 @@
} else { } else {
JHW.stdout.print('F'.foreground('red')); JHW.stdout.print('F'.foreground('red'));
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation()); JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
JHW.hasError();
this.failedCount++; this.failedCount++;
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()); failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName());
testCount = 1; testCount = 1;

View File

@ -37,9 +37,13 @@
} }
}; };
window.onbeforeunload = function(e) { window.onbeforeunload = function(e) {
JHW.stderr.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.'); e = e || window.event;
JHW.hasError(); JHW.hasError();
return false; JHW.stdout.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.');
if (e) {
e.returnValue = 'string';
}
return 'string';
}; };
window.confirm = function(message) { window.confirm = function(message) {
JHW.stderr.puts("" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true."); JHW.stderr.puts("" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.");