2011-05-12 21:02:11 +00:00
|
|
|
(function() {
|
|
|
|
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
|
2011-06-13 12:14:24 +00:00
|
|
|
throw new Error("jasmine not laoded!");
|
2011-05-12 21:02:11 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
jasmine.HeadlessReporter = (function() {
|
|
|
|
function HeadlessReporter(callback) {
|
|
|
|
this.callback = callback != null ? callback : null;
|
|
|
|
this.results = [];
|
|
|
|
this.failedCount = 0;
|
|
|
|
this.length = 0;
|
|
|
|
}
|
|
|
|
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
|
|
|
|
var result, resultLine, runtime, _i, _len, _ref;
|
|
|
|
if (this.hasError()) {
|
|
|
|
return;
|
2011-05-12 21:02:11 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
if (this.callback) {
|
|
|
|
this.callback();
|
2011-07-13 18:42:47 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
runtime = (new Date() - this.startTime) / 1000.0;
|
|
|
|
JHW.stdout.print("\n");
|
|
|
|
resultLine = this._formatResultLine(runtime);
|
|
|
|
if (this.failedCount === 0) {
|
|
|
|
JHW.stdout.puts(("PASS: " + resultLine).foreground('green'));
|
|
|
|
} else {
|
|
|
|
JHW.stdout.puts(("FAIL: " + resultLine).foreground('red'));
|
|
|
|
}
|
|
|
|
_ref = this.results;
|
2011-05-12 21:02:11 +00:00
|
|
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2011-10-24 20:40:08 +00:00
|
|
|
result = _ref[_i];
|
|
|
|
result.print();
|
2011-07-22 11:42:25 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
return JHW.finishSuite();
|
2011-05-12 22:47:56 +00:00
|
|
|
};
|
2011-10-24 20:40:08 +00:00
|
|
|
HeadlessReporter.prototype.reportRunnerStarting = function(runner) {
|
|
|
|
this.startTime = new Date();
|
|
|
|
return JHW.stdout.puts("Running Jasmine specs...");
|
2011-05-12 21:02:11 +00:00
|
|
|
};
|
2011-10-24 20:40:08 +00:00
|
|
|
HeadlessReporter.prototype.reportSpecResults = function(spec) {
|
|
|
|
var failureResult, foundLine, result, results, testCount, _i, _len, _ref;
|
|
|
|
if (this.hasError()) {
|
|
|
|
return;
|
2011-08-07 18:45:57 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
results = spec.results();
|
|
|
|
this.length++;
|
|
|
|
if (results.passed()) {
|
|
|
|
JHW.stdout.print('.'.foreground('green'));
|
|
|
|
return JHW.report.puts("PASS||" + spec.getJHWSpecInformation());
|
|
|
|
} else {
|
|
|
|
JHW.stdout.print('F'.foreground('red'));
|
|
|
|
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
|
|
|
|
this.failedCount++;
|
|
|
|
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName());
|
|
|
|
testCount = 1;
|
|
|
|
_ref = results.getItems();
|
2011-05-12 21:02:11 +00:00
|
|
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
result = _ref[_i];
|
2011-10-24 20:40:08 +00:00
|
|
|
if (result.type === 'expect' && !result.passed_) {
|
|
|
|
if (foundLine = result.expectations[testCount - 1]) {
|
|
|
|
result.line = foundLine[0], result.lineNumber = foundLine[1];
|
2011-09-12 19:12:58 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
failureResult.addResult(result);
|
2011-07-22 13:40:40 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
testCount += 1;
|
2011-05-12 21:02:11 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
return this.results.push(failureResult);
|
2011-08-07 18:45:57 +00:00
|
|
|
}
|
2011-10-24 20:40:08 +00:00
|
|
|
};
|
|
|
|
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
|
|
|
|
if (this.hasError()) {
|
|
|
|
spec.finish();
|
|
|
|
return spec.suite.finish();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
|
|
|
|
HeadlessReporter.prototype.hasError = function() {
|
2011-10-25 19:41:22 +00:00
|
|
|
return JHW._hasErrors;
|
2011-10-24 20:40:08 +00:00
|
|
|
};
|
|
|
|
HeadlessReporter.prototype._formatResultLine = function(runtime) {
|
|
|
|
var line;
|
|
|
|
line = [];
|
|
|
|
line.push(this.length);
|
|
|
|
line.push((this.length === 1 ? "test" : "tests") + ',');
|
|
|
|
line.push(this.failedCount);
|
|
|
|
line.push((this.failedCount === 1 ? "failure" : "failures") + ',');
|
|
|
|
line.push(runtime);
|
|
|
|
line.push((runtime === 1.0 ? "sec" : "secs") + '.');
|
|
|
|
return line.join(' ');
|
|
|
|
};
|
|
|
|
return HeadlessReporter;
|
|
|
|
})();
|
2011-05-12 21:02:11 +00:00
|
|
|
}).call(this);
|