mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-01 19:35:23 +03:00
Use terminal reporter from jasmine-node
This gives the same filtered stack traces and text output as all our node modules that already use jasmine-node indirectly through jasmine-focused.
This commit is contained in:
parent
8307ae8938
commit
e0ccfc4788
@ -117,7 +117,8 @@
|
||||
"js-yaml": "~2.1.0",
|
||||
"grunt-markdown": "~0.4.0",
|
||||
"json-front-matter": "~0.1.3",
|
||||
"grunt-shell": "~0.3.1"
|
||||
"grunt-shell": "~0.3.1",
|
||||
"jasmine-node": "git://github.com/kevinsawicki/jasmine-node.git#short-stacks"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -11,7 +11,6 @@ window.nakedLoad = (file) ->
|
||||
module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
{$$} = require 'space-pen'
|
||||
nakedLoad 'jasmine'
|
||||
nakedLoad 'jasmine-console-reporter'
|
||||
require 'jasmine-focused'
|
||||
|
||||
AtomReporter = require 'atom-reporter'
|
||||
@ -19,19 +18,22 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
$ = require 'jquery'
|
||||
TimeReporter = require 'time-reporter'
|
||||
|
||||
reporter = if atom.getLoadSettings().exitWhenDone
|
||||
new jasmine.ConsoleReporter(document, logErrors)
|
||||
if atom.getLoadSettings().exitWhenDone
|
||||
{jasmineNode} = require 'jasmine-node/lib/jasmine-node/reporter'
|
||||
reporter = new jasmineNode.TerminalReporter
|
||||
print: (args...) ->
|
||||
process.stderr.write(args...)
|
||||
onComplete: (runner) ->
|
||||
atom.exit(runner.results().failedCount > 0 ? 1 : 0)
|
||||
else
|
||||
new AtomReporter()
|
||||
reporter = new AtomReporter()
|
||||
|
||||
require specSuite
|
||||
|
||||
jasmineEnv = jasmine.getEnv()
|
||||
jasmineEnv.addReporter(reporter)
|
||||
|
||||
jasmineEnv.addReporter(new TimeReporter())
|
||||
jasmineEnv.specFilter = (spec) -> reporter.specFilter(spec)
|
||||
|
||||
$('body').append $$ ->
|
||||
@div id: 'jasmine-content'
|
||||
$('body').append $$ -> @div id: 'jasmine-content'
|
||||
|
||||
jasmineEnv.execute()
|
||||
|
91
vendor/jasmine-console-reporter.js
vendored
91
vendor/jasmine-console-reporter.js
vendored
@ -1,91 +0,0 @@
|
||||
var _ = require('underscore');
|
||||
var convertStackTrace = require('coffeestack').convertStackTrace;
|
||||
|
||||
var sourceMaps = {};
|
||||
var formatStackTrace = function(stackTrace) {
|
||||
if (!stackTrace)
|
||||
return stackTrace;
|
||||
|
||||
// Remove all lines containing jasmine.js path
|
||||
var jasminePath = require.resolve('jasmine');
|
||||
var jasminePattern = new RegExp("\\(" + _.escapeRegExp(jasminePath) + ":\\d+:\\d+\\)\\s*$");
|
||||
var convertedLines = [];
|
||||
var lines = stackTrace.split('\n');
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
if (!jasminePattern.test(lines[i]))
|
||||
convertedLines.push(lines[i]);
|
||||
|
||||
//Remove last util.spawn.callDone line and all lines after it
|
||||
var gruntSpawnPattern = /^\s*at util\.spawn\.callDone\s*\(.*\/grunt\/util\.js:\d+:\d+\)\s*$/
|
||||
for (var i = convertedLines.length - 1; i > 0; i--)
|
||||
if (gruntSpawnPattern.test(convertedLines[i])) {
|
||||
convertedLines = convertedLines.slice(0, i);
|
||||
break;
|
||||
}
|
||||
|
||||
return convertStackTrace(convertedLines.join('\n'), sourceMaps);
|
||||
}
|
||||
|
||||
jasmine.ConsoleReporter = function(doc, logErrors) {
|
||||
this.logErrors = logErrors == false ? false : true
|
||||
};
|
||||
|
||||
jasmine.ConsoleReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
var suites = runner.suites();
|
||||
this.startedAt = new Date();
|
||||
};
|
||||
|
||||
jasmine.ConsoleReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var specs = runner.specs();
|
||||
var specCount = specs.legnth;
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
|
||||
atom.exit(results.failedCount > 0 ? 1 : 0)
|
||||
};
|
||||
|
||||
jasmine.ConsoleReporter.prototype.reportSuiteResults = function(suite) {
|
||||
};
|
||||
|
||||
jasmine.ConsoleReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var resultItems = results.getItems();
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
if (this.logErrors && result.type == 'expect' && result.passed && !result.passed()) {
|
||||
message = spec.getFullName()
|
||||
console.log("\n\n" + message)
|
||||
console.log((new Array(message.length + 1)).join('-'))
|
||||
if (result.trace.stack) {
|
||||
console.log(formatStackTrace(result.trace.stack));
|
||||
}
|
||||
else {
|
||||
console.log(result.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.ConsoleReporter.prototype.specFilter = function(spec) {
|
||||
var globalFocusPriority = jasmine.getEnv().focusPriority
|
||||
var parent = spec.parentSuite || spec.suite
|
||||
|
||||
if (!globalFocusPriority) {
|
||||
return true
|
||||
}
|
||||
else if (spec.focusPriority >= globalFocusPriority) {
|
||||
return true
|
||||
}
|
||||
else if (!parent) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
return this.specFilter(parent)
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user