don't process any more specs when there's an error, makes the output make more sense on super-fast computers when errors occur

This commit is contained in:
John Bintz 2011-08-07 14:45:57 -04:00
parent 96c69f3def
commit 77a14311aa
6 changed files with 53 additions and 1 deletions

View File

@ -12,3 +12,4 @@ gem 'guard-coffeescript'
gem 'growl'
gem 'rake', '0.8.7'
gem 'mocha', '0.9.12'
gem 'guard-jasmine-headless-webkit'

View File

@ -83,6 +83,10 @@ namespace HeadlessSpecRunner {
if (showColors) std::cout << "\033[0;32m";
}
bool Runner::hasError() {
return hasErrors;
}
void Runner::yellow()
{
if (showColors) std::cout << "\033[0;33m";

View File

@ -21,6 +21,7 @@ namespace HeadlessSpecRunner {
void go();
public slots:
void log(const QString &msg);
bool hasError();
void leavePageAttempt(const QString &msg);
void specPassed();
void specFailed(const QString &specDetail);

View File

@ -54,6 +54,8 @@ class jasmine.HeadlessReporter
@failedCount = 0
@length = 0
reportRunnerResults: (runner) ->
return if this.hasError()
for result in @results
result.print()
@ -62,6 +64,8 @@ class jasmine.HeadlessReporter
reportRunnerStarting: (runner) ->
@startTime = new Date()
reportSpecResults: (spec) ->
return if this.hasError()
results = spec.results()
@length++
if results.passed()
@ -75,4 +79,10 @@ class jasmine.HeadlessReporter
failureResult.addResult(result.message)
@results.push(failureResult)
reportSpecStarting: (spec) ->
if this.hasError()
spec.finish()
spec.suite.finish()
reportSuiteResults: (suite) ->
hasError: ->
JHW.hasError()

View File

@ -88,6 +88,9 @@
}
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
var result, _i, _len, _ref;
if (this.hasError()) {
return;
}
_ref = this.results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
@ -103,6 +106,9 @@
};
HeadlessReporter.prototype.reportSpecResults = function(spec) {
var failureResult, result, results, _i, _len, _ref;
if (this.hasError()) {
return;
}
results = spec.results();
this.length++;
if (results.passed()) {
@ -121,8 +127,16 @@
return this.results.push(failureResult);
}
};
HeadlessReporter.prototype.reportSpecStarting = function(spec) {};
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
if (this.hasError()) {
spec.finish();
return spec.suite.finish();
}
};
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
HeadlessReporter.prototype.hasError = function() {
return JHW.hasError();
};
return HeadlessReporter;
})();
}).call(this);

View File

@ -14,3 +14,25 @@ describe 'HeadlessReporterResult', ->
result = new HeadlessReporterResult('test', [ 'other', 'of', 'test' ])
expect(result._findSpecLine().lineNumber).toEqual(10)
describe 'jasmine.HeadlessReporter', ->
reporter = null
beforeEach ->
reporter = new jasmine.HeadlessReporter()
it 'should stop running specs if there are errors reported', ->
# otherwise it gets really confusing!
suite = { finish: -> null }
spec = new jasmine.Spec("env", suite, "test")
spyOn(reporter, 'hasError').andReturn(true)
spyOn(spec, 'finish')
spyOn(suite, 'finish')
reporter.reportSpecStarting(spec)
expect(spec.finish).toHaveBeenCalled()
expect(suite.finish).toHaveBeenCalled()