start splitting the reporters out

This commit is contained in:
John Bintz 2011-12-12 12:22:32 -05:00
parent 4e64480c69
commit e03389e938
16 changed files with 422 additions and 254 deletions

View File

@ -139,6 +139,7 @@ void Runner::print(const QString &fh, const QString &content) {
void Runner::finishSuite() { void Runner::finishSuite() {
isFinished = true; isFinished = true;
runs = 0;
} }
void Runner::timerEvent() { void Runner::timerEvent() {
@ -147,7 +148,7 @@ void Runner::timerEvent() {
if (hasErrors && runs > 2) if (hasErrors && runs > 2)
QApplication::instance()->exit(1); QApplication::instance()->exit(1);
if (isFinished) { if (isFinished && runs > 2) {
if (outputFile) { if (outputFile) {
outputFile->close(); outputFile->close();
} }

View File

@ -61,7 +61,9 @@ module Jasmine::Headless
end end
def default_files def default_files
%w{jasmine.js jasmine-html jasmine.css jasmine-extensions intense headless_reporter_result jasmine.HeadlessConsoleReporter jsDump beautify-html} %w{jasmine.js jasmine-html jasmine.css jasmine-extensions
intense headless_reporter_result jasmine.HeadlessReporter
jasmine.HeadlessFileReporter jasmine.HeadlessConsoleReporter jsDump beautify-html}
end end
def extension_filter def extension_filter

View File

@ -24,6 +24,7 @@
if (window.JHW) { if (window.JHW) {
jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter()); jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter());
jasmine.getEnv().addReporter(new jasmine.HeadlessFileReporter());
} else { } else {
types = [ 'HtmlReporter', 'TrivialReporter' ]; types = [ 'HtmlReporter', 'TrivialReporter' ];

View File

@ -4,6 +4,7 @@ describe 'HeadlessReporterResult', ->
splitName = "splitName" splitName = "splitName"
message = 'message' message = 'message'
context 'no lines', ->
beforeEach -> beforeEach ->
result = new HeadlessReporterResult(name, splitName) result = new HeadlessReporterResult(name, splitName)
@ -12,3 +13,18 @@ describe 'HeadlessReporterResult', ->
result.addResult(message) result.addResult(message)
expect(result.results).toEqual([ message ]) expect(result.results).toEqual([ message ])
context 'with lines', ->
beforeEach ->
HeadlessReporterResult.specLineNumbers = {
'one': {
'name': [ 1 ],
'of': [ 2, 9 ],
'test': [ 3, 10 ],
'other': [ 7 ]
}
}
it 'should find the best spec lines', ->
expect(HeadlessReporterResult.findSpecLine([ 'name', 'of', 'test' ]).lineNumber).toEqual(3)
expect(HeadlessReporterResult.findSpecLine([ 'other', 'of', 'test' ]).lineNumber).toEqual(10)

View File

@ -0,0 +1,2 @@
window.context = window.describe

View File

@ -0,0 +1,80 @@
describe 'jasmine.Suite.prototype.getSuiteSplitName', ->
it 'should flatten the description', ->
suite = new jasmine.Suite({});
suite.description = "hello\ngoodbye\n";
expect(suite.getSuiteSplitName()).toEqual([ "hello goodbye " ])
it 'should not fail on missing description', ->
suite = new jasmine.Suite({});
suite.description = 1;
expect(suite.getSuiteSplitName()).toEqual([ "1" ])
describe 'jasmine.Spec.prototype.getSuiteSplitName', ->
it 'should flatten the description', ->
spec = new jasmine.Spec({}, {});
spec.suite = {
getSuiteSplitName: -> []
}
spec.description = "hello\ngoodbye\n";
expect(spec.getSpecSplitName()).toEqual([ "hello goodbye " ])
it 'should not fail on missing description', ->
spec = new jasmine.Spec({}, {});
spec.suite = {
getSuiteSplitName: -> []
}
spec.description = 1
expect(spec.getSpecSplitName()).toEqual([ "1" ])
describe 'jasmine.Spec.prototype.getJHWSpecInformation', ->
it 'should append null when there is no file information', ->
spec = new jasmine.Spec({}, {})
spyOn(spec, 'getSpecSplitName').andReturn(["one"])
spyOn(HeadlessReporterResult, 'findSpecLine').andReturn({})
expect(spec.getJHWSpecInformation()).toEqual("one||")
describe 'jasmine.WaitsBlock and jasmine.WaitsForBlock', ->
beforeEach ->
it 'should notify JHW of waiting', ->
waits(5500)
runs ->
expect(true).toEqual(true)
it 'should notify JHW of waiting for something', ->
value = false
setTimeout(
->
value = true
, 5000
)
waitsFor(
->
value
, "Nope"
5500
)
runs ->
expect(true).toEqual(true)
describe 'jasmine.NestedResults.isValidSpecLine', ->
it 'should check the lines', ->
expect(jasmine.NestedResults.isValidSpecLine('yes')).toEqual(false)
expect(jasmine.NestedResults.isValidSpecLine('expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine(' expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine('return expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine(' return expect')).toEqual(true)
describe 'jasmine.nestedResults.parseFunction', ->
it 'should parse the function', ->
expect(jasmine.NestedResults.parseFunction("""
test
expect("cat")
return expect("dog")
""")).toEqual([
[ 'expect("cat")', 1 ],
[ 'expect("dog")', 2 ]
])

View File

@ -1,16 +1,4 @@
describe 'HeadlessReporterResult', -> describe 'HeadlessReporterResult', ->
beforeEach ->
HeadlessReporterResult.specLineNumbers = {
'one': {
'name': [ 1 ],
'of': [ 2, 9 ],
'test': [ 3, 10 ],
'other': [ 7 ]
}
}
it 'should find the best spec lines', ->
expect(HeadlessReporterResult.findSpecLine([ 'name', 'of', 'test' ]).lineNumber).toEqual(3)
expect(HeadlessReporterResult.findSpecLine([ 'other', 'of', 'test' ]).lineNumber).toEqual(10)
describe 'jasmine.HeadlessConsoleReporter', -> describe 'jasmine.HeadlessConsoleReporter', ->
reporter = null reporter = null
@ -18,98 +6,32 @@ describe 'jasmine.HeadlessConsoleReporter', ->
beforeEach -> beforeEach ->
reporter = new jasmine.HeadlessConsoleReporter() reporter = new jasmine.HeadlessConsoleReporter()
it 'should stop running specs if there are errors reported', -> describe '#formatResultLine', ->
# otherwise it gets really confusing! context 'length = 1', ->
it 'should format', ->
reporter.length = 1
expect(reporter.formatResultLine(0)).toMatch(/test,/)
suite = { finish: -> null } context 'length != 1', ->
spec = new jasmine.Spec("env", suite, "test") it 'should format', ->
reporter.length = 2
expect(reporter.formatResultLine(0)).toMatch(/tests,/)
spyOn(reporter, 'hasError').andReturn(true) context 'failedCount = 1', ->
spyOn(spec, 'finish') it 'should format', ->
spyOn(suite, 'finish') reporter.failedCount = 1
expect(reporter.formatResultLine(0)).toMatch(/failure,/)
reporter.reportSpecStarting(spec) context 'failedCount != 1', ->
it 'should format', ->
reporter.failedCount = 0
expect(reporter.formatResultLine(0)).toMatch(/failures,/)
expect(spec.finish).toHaveBeenCalled() context 'runtime = 1', ->
expect(suite.finish).toHaveBeenCalled() it 'should format', ->
expect(reporter.formatResultLine(1)).toMatch(/sec./)
describe 'jasmine.Suite.prototype.getSuiteSplitName', -> context 'runtime != 1', ->
it 'should flatten the description', -> it 'should format', ->
suite = new jasmine.Suite({}); expect(reporter.formatResultLine(0)).toMatch(/secs./)
suite.description = "hello\ngoodbye\n";
expect(suite.getSuiteSplitName()).toEqual([ "hello goodbye " ])
it 'should not fail on missing description', ->
suite = new jasmine.Suite({});
suite.description = 1;
expect(suite.getSuiteSplitName()).toEqual([ "1" ])
describe 'jasmine.Spec.prototype.getSuiteSplitName', ->
it 'should flatten the description', ->
spec = new jasmine.Spec({}, {});
spec.suite = {
getSuiteSplitName: -> []
}
spec.description = "hello\ngoodbye\n";
expect(spec.getSpecSplitName()).toEqual([ "hello goodbye " ])
it 'should not fail on missing description', ->
spec = new jasmine.Spec({}, {});
spec.suite = {
getSuiteSplitName: -> []
}
spec.description = 1
expect(spec.getSpecSplitName()).toEqual([ "1" ])
describe 'jasmine.Spec.prototype.getJHWSpecInformation', ->
it 'should append null when there is no file information', ->
spec = new jasmine.Spec({}, {})
spyOn(spec, 'getSpecSplitName').andReturn(["one"])
spyOn(HeadlessReporterResult, 'findSpecLine').andReturn({})
expect(spec.getJHWSpecInformation()).toEqual("one||")
describe 'jasmine.WaitsBlock and jasmine.WaitsForBlock', ->
beforeEach ->
it 'should notify JHW of waiting', ->
waits(5500)
runs ->
expect(true).toEqual(true)
it 'should notify JHW of waiting for something', ->
value = false
setTimeout(
->
value = true
, 5000
)
waitsFor(
->
value
, "Nope"
5500
)
runs ->
expect(true).toEqual(true)
describe 'jasmine.NestedResults.isValidSpecLine', ->
it 'should check the lines', ->
expect(jasmine.NestedResults.isValidSpecLine('yes')).toEqual(false)
expect(jasmine.NestedResults.isValidSpecLine('expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine(' expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine('return expect')).toEqual(true)
expect(jasmine.NestedResults.isValidSpecLine(' return expect')).toEqual(true)
describe 'jasmine.nestedResults.parseFunction', ->
it 'should parse the function', ->
expect(jasmine.NestedResults.parseFunction("""
test
expect("cat")
return expect("dog")
""")).toEqual([
[ 'expect("cat")', 1 ],
[ 'expect("dog")', 2 ]
])

View File

@ -0,0 +1,27 @@
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()
describe '#reportRunnerStarting', ->
it 'should start getting time', ->
expect(reporter.startTime).not.toBeDefined()
reporter.reportRunnerStarting("runner")
expect(reporter.startTime).toBeDefined()

View File

@ -1,8 +1,9 @@
src_files: src_files:
- 'spec/javascripts/support/jquery-1.6.2.min.js' - '**/*'
- 'vendor/assets/coffeescripts/*.coffee'
spec_files: [ 'spec/javascripts/*_spec.coffee' ] spec_files: [ '**/*_spec.coffee' ]
src_dir: . src_dir: vendor/assets/javascripts
spec_dir: . spec_dir: spec/javascripts
helpers:
- 'helpers/**.*'

View File

@ -14,6 +14,8 @@ describe Jasmine::Headless::FilesList do
File.expand_path('vendor/assets/javascripts/jasmine-extensions.js'), File.expand_path('vendor/assets/javascripts/jasmine-extensions.js'),
File.expand_path('vendor/assets/javascripts/intense.js'), File.expand_path('vendor/assets/javascripts/intense.js'),
File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'), File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'),
File.expand_path('vendor/assets/javascripts/jasmine.HeadlessReporter.js'),
File.expand_path('vendor/assets/javascripts/jasmine.HeadlessFileReporter.js'),
File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'), File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'),
File.expand_path('vendor/assets/javascripts/jsDump.js'), File.expand_path('vendor/assets/javascripts/jsDump.js'),
File.expand_path('vendor/assets/javascripts/beautify-html.js'), File.expand_path('vendor/assets/javascripts/beautify-html.js'),

View File

@ -1,33 +1,23 @@
if !jasmine? #= require jasmine.HeadlessReporter.js
throw new Error("jasmine not loaded!") #
class jasmine.HeadlessConsoleReporter extends jasmine.HeadlessReporter
class jasmine.HeadlessConsoleReporter
constructor: (@callback = null) -> constructor: (@callback = null) ->
@results = [] super(@callback)
@failedCount = 0
@length = 0
@timer = null
@position = 0 @position = 0
@positions = "|/-\\" @positions = "|/-\\"
reportRunnerResults: (runner) -> reportRunnerResults: (runner) ->
return if this.hasError() super()
runtime = (new Date() - @startTime) / 1000.0
JHW.stdout.print("\n") JHW.stdout.print("\n")
resultLine = this._formatResultLine(runtime) resultLine = this.formatResultLine(this._runtime())
if @failedCount == 0 if @failedCount == 0
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"}"
JHW.report.puts(output)
for result in @results for result in @results
JHW.stdout.puts(result.toString()) JHW.stdout.puts(result.toString())
@ -35,27 +25,19 @@ class jasmine.HeadlessConsoleReporter
if window.JHW if window.JHW
window.onbeforeunload = null window.onbeforeunload = null
JHW.finishSuite()
reportRunnerStarting: (runner) -> reportRunnerStarting: (runner) ->
@startTime = new Date() super(runner)
JHW.stdout.puts("\nRunning Jasmine specs...".bright()) if !this.hasError() JHW.stdout.puts("\nRunning Jasmine specs...".bright()) if !this.hasError()
reportSpecResults: (spec) -> reportSpecResults: (spec) ->
return if this.hasError() super(spec)
JHW.ping()
results = spec.results() this._reportSpecResult(spec, {
success: (results) =>
@length++
if results.passed()
JHW.stdout.print('.'.foreground('green')) JHW.stdout.print('.'.foreground('green'))
JHW.report.puts("PASS||" + spec.getJHWSpecInformation()) failure: (results) =>
else
JHW.stdout.print('F'.foreground('red')) JHW.stdout.print('F'.foreground('red'))
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
@failedCount++
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()) failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
testCount = 1 testCount = 1
@ -66,32 +48,14 @@ class jasmine.HeadlessConsoleReporter
failureResult.addResult(result) failureResult.addResult(result)
testCount += 1 testCount += 1
@results.push(failureResult) @results.push(failureResult)
})
reportSpecStarting: (spec) ->
if this.hasError()
spec.finish()
spec.suite.finish()
reportSpecWaiting: -> reportSpecWaiting: ->
runner = null
if !@timer if !@timer
@timer = true @timer = true
first = true @first = true
runner = => this._waitRunner()
@timer = setTimeout(
=>
if @timer
JHW.stdout.print(Intense.moveBack()) if !first
JHW.stdout.print(@positions.substr(@position, 1).foreground('yellow'))
@position += 1
@position %= @positions.length
first = false
runner()
, 750
)
runner()
reportSpecRunning: -> reportSpecRunning: ->
if @timer if @timer
@ -99,11 +63,7 @@ class jasmine.HeadlessConsoleReporter
@timer = null @timer = null
JHW.stdout.print(Intense.moveBack()) JHW.stdout.print(Intense.moveBack())
reportSuiteResults: (suite) -> formatResultLine: (runtime) ->
hasError: ->
JHW._hasErrors
_formatResultLine: (runtime) ->
line = [] line = []
line.push(@length) line.push(@length)
line.push((if @length == 1 then "test" else "tests") + ',') line.push((if @length == 1 then "test" else "tests") + ',')
@ -116,3 +76,15 @@ class jasmine.HeadlessConsoleReporter
line.join(' ') line.join(' ')
_waitRunner: =>
@timer = setTimeout(
=>
if @timer
JHW.stdout.print(Intense.moveBack()) if !@first
JHW.stdout.print(@positions.substr(@position, 1).foreground('yellow'))
@position += 1
@position %= @positions.length
@first = false
this._waitRunner()
, 750
)

View File

@ -0,0 +1,17 @@
class jasmine.HeadlessFileReporter extends jasmine.HeadlessReporter
reportRunnerResults: (runner) ->
super(runner)
output = "TOTAL||#{@length}||#{@failedCount}||#{this._runtime()}||#{if JHW._hasErrors then "T" else "F"}"
JHW.report.puts(output)
reportSpecResults: (spec) ->
super(spec)
this._reportSpecResult(spec, {
success: (results) =>
JHW.report.puts("PASS||" + spec.getJHWSpecInformation())
failure: (results) =>
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
})

View File

@ -0,0 +1,48 @@
if !jasmine?
throw new Error("jasmine not loaded!")
class jasmine.HeadlessReporter
constructor: (@callback = null) ->
@results = []
@failedCount = 0
@length = 0
@timer = null
hasError: ->
JHW._hasErrors
reportSpecStarting: (spec) ->
if this.hasError()
spec.finish()
spec.suite.finish()
reportSuiteResults: (suite) ->
reportRunnerStarting: (runner) ->
@startTime = new Date()
reportRunnerResults: (runner) ->
return if this.hasError()
if @failedCount != 0
JHW.hasSpecFailure()
JHW.finishSuite()
reportSpecResults: (spec) ->
return if this.hasError()
JHW.ping()
_reportSpecResult: (spec, options) ->
results = spec.results()
@length++
if results.passed()
options.success(results, spec)
else
@failedCount++
options.failure(results, spec)
_runtime: ->
(new Date() - @startTime) / 1000.0

View File

@ -1,63 +1,53 @@
(function() {
if (!(typeof jasmine !== "undefined" && jasmine !== null)) { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
throw new Error("jasmine not loaded!");
}
jasmine.HeadlessConsoleReporter = (function() { jasmine.HeadlessConsoleReporter = (function() {
__extends(HeadlessConsoleReporter, jasmine.HeadlessReporter);
function HeadlessConsoleReporter(callback) { function HeadlessConsoleReporter(callback) {
this.callback = callback != null ? callback : null; this.callback = callback != null ? callback : null;
this.results = []; this._waitRunner = __bind(this._waitRunner, this);
this.failedCount = 0; HeadlessConsoleReporter.__super__.constructor.call(this, this.callback);
this.length = 0;
this.timer = null;
this.position = 0; this.position = 0;
this.positions = "|/-\\"; this.positions = "|/-\\";
} }
HeadlessConsoleReporter.prototype.reportRunnerResults = function(runner) { HeadlessConsoleReporter.prototype.reportRunnerResults = function(runner) {
var output, result, resultLine, runtime, _i, _len, _ref; var result, resultLine, _i, _len, _ref;
if (this.hasError()) return; HeadlessConsoleReporter.__super__.reportRunnerResults.call(this);
runtime = (new Date() - this.startTime) / 1000.0;
JHW.stdout.print("\n"); JHW.stdout.print("\n");
resultLine = this._formatResultLine(runtime); resultLine = this.formatResultLine(this._runtime());
if (this.failedCount === 0) { if (this.failedCount === 0) {
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");
JHW.report.puts(output);
_ref = this.results; _ref = this.results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i]; result = _ref[_i];
JHW.stdout.puts(result.toString()); JHW.stdout.puts(result.toString());
} }
if (window.JHW) window.onbeforeunload = null; if (window.JHW) return window.onbeforeunload = null;
return JHW.finishSuite();
}; };
HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) { HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) {
this.startTime = new Date(); HeadlessConsoleReporter.__super__.reportRunnerStarting.call(this, runner);
if (!this.hasError()) { if (!this.hasError()) {
return JHW.stdout.puts("\nRunning Jasmine specs...".bright()); return JHW.stdout.puts("\nRunning Jasmine specs...".bright());
} }
}; };
HeadlessConsoleReporter.prototype.reportSpecResults = function(spec) { HeadlessConsoleReporter.prototype.reportSpecResults = function(spec) {
var failureResult, foundLine, result, results, testCount, _i, _len, _ref; var _this = this;
if (this.hasError()) return; HeadlessConsoleReporter.__super__.reportSpecResults.call(this, spec);
JHW.ping(); return this._reportSpecResult(spec, {
results = spec.results(); success: function(results) {
this.length++; return JHW.stdout.print('.'.foreground('green'));
if (results.passed()) { },
JHW.stdout.print('.'.foreground('green')); failure: function(results) {
return JHW.report.puts("PASS||" + spec.getJHWSpecInformation()); var failureResult, foundLine, result, testCount, _i, _len, _ref;
} else {
JHW.stdout.print('F'.foreground('red')); JHW.stdout.print('F'.foreground('red'));
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
this.failedCount++;
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()); failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName());
testCount = 1; testCount = 1;
_ref = results.getItems(); _ref = results.getItems();
@ -71,37 +61,16 @@
} }
testCount += 1; testCount += 1;
} }
return this.results.push(failureResult); return _this.results.push(failureResult);
}
};
HeadlessConsoleReporter.prototype.reportSpecStarting = function(spec) {
if (this.hasError()) {
spec.finish();
return spec.suite.finish();
} }
});
}; };
HeadlessConsoleReporter.prototype.reportSpecWaiting = function() { HeadlessConsoleReporter.prototype.reportSpecWaiting = function() {
var first, runner;
var _this = this;
runner = null;
if (!this.timer) { if (!this.timer) {
this.timer = true; this.timer = true;
first = true; this.first = true;
runner = function() { return this._waitRunner();
return _this.timer = setTimeout(function() {
if (_this.timer) {
if (!first) JHW.stdout.print(Intense.moveBack());
JHW.stdout.print(_this.positions.substr(_this.position, 1).foreground('yellow'));
_this.position += 1;
_this.position %= _this.positions.length;
first = false;
return runner();
}
}, 750);
};
return runner();
} }
}; };
@ -113,13 +82,7 @@
} }
}; };
HeadlessConsoleReporter.prototype.reportSuiteResults = function(suite) {}; HeadlessConsoleReporter.prototype.formatResultLine = function(runtime) {
HeadlessConsoleReporter.prototype.hasError = function() {
return JHW._hasErrors;
};
HeadlessConsoleReporter.prototype._formatResultLine = function(runtime) {
var line; var line;
line = []; line = [];
line.push(this.length); line.push(this.length);
@ -131,6 +94,22 @@
return line.join(' '); return line.join(' ');
}; };
HeadlessConsoleReporter.prototype._waitRunner = function() {
var _this = this;
return this.timer = setTimeout(function() {
if (_this.timer) {
if (!_this.first) JHW.stdout.print(Intense.moveBack());
JHW.stdout.print(_this.positions.substr(_this.position, 1).foreground('yellow'));
_this.position += 1;
_this.position %= _this.positions.length;
_this.first = false;
return _this._waitRunner();
}
}, 750);
};
return HeadlessConsoleReporter; return HeadlessConsoleReporter;
})(); })();
}).call(this);

View File

@ -0,0 +1,36 @@
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessFileReporter = (function() {
__extends(HeadlessFileReporter, jasmine.HeadlessReporter);
function HeadlessFileReporter() {
HeadlessFileReporter.__super__.constructor.apply(this, arguments);
}
HeadlessFileReporter.prototype.reportRunnerResults = function(runner) {
var output;
HeadlessFileReporter.__super__.reportRunnerResults.call(this, runner);
output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + (this._runtime()) + "||" + (JHW._hasErrors ? "T" : "F");
return JHW.report.puts(output);
};
HeadlessFileReporter.prototype.reportSpecResults = function(spec) {
var _this = this;
HeadlessFileReporter.__super__.reportSpecResults.call(this, spec);
return this._reportSpecResult(spec, {
success: function(results) {
return JHW.report.puts("PASS||" + spec.getJHWSpecInformation());
},
failure: function(results) {
return JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
}
});
};
return HeadlessFileReporter;
})();
}).call(this);

View File

@ -0,0 +1,62 @@
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
throw new Error("jasmine not loaded!");
}
jasmine.HeadlessReporter = (function() {
function HeadlessReporter(callback) {
this.callback = callback != null ? callback : null;
this.results = [];
this.failedCount = 0;
this.length = 0;
this.timer = null;
}
HeadlessReporter.prototype.hasError = function() {
return JHW._hasErrors;
};
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
if (this.hasError()) {
spec.finish();
return spec.suite.finish();
}
};
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
HeadlessReporter.prototype.reportRunnerStarting = function(runner) {
return this.startTime = new Date();
};
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
if (this.hasError()) return;
if (this.failedCount !== 0) JHW.hasSpecFailure();
return JHW.finishSuite();
};
HeadlessReporter.prototype.reportSpecResults = function(spec) {
if (this.hasError()) return;
return JHW.ping();
};
HeadlessReporter.prototype._reportSpecResult = function(spec, options) {
var results;
results = spec.results();
this.length++;
if (results.passed()) {
return options.success(results, spec);
} else {
this.failedCount++;
return options.failure(results, spec);
}
};
HeadlessReporter.prototype._runtime = function() {
return (new Date() - this.startTime) / 1000.0;
};
return HeadlessReporter;
})();