This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
227 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
var util = require('util'); | ||
|
||
// Method to format test results. | ||
var strutils = require('./strutils'); | ||
|
||
function resultDisplay(id, prefix, result) { | ||
|
||
var parts = []; | ||
if (prefix) { | ||
parts.push(prefix); | ||
} | ||
if (result.name) { | ||
parts.push(result.name.trim()); | ||
} | ||
|
||
var line = parts.join(' - '); | ||
return (result.skipped ? 'skip ' : (result.passed ? 'ok ' : 'not ok ')) + id + ' ' + line; | ||
} | ||
|
||
function yamlDisplay(err, logs) { | ||
var testLogs; | ||
var failed = Object.keys(err || {}) | ||
.filter(function(key) { | ||
return key !== 'passed'; | ||
}) | ||
.map(function(key) { | ||
return key + ': >\n' + strutils.indent(String(err[key])); | ||
}); | ||
if (logs) { | ||
testLogs = ['Log: |'].concat(logs.map(function(log) {return strutils.indent(util.inspect(log));})); | ||
} else { | ||
testLogs = []; | ||
} | ||
return strutils.indent([ | ||
'---', | ||
strutils.indent(failed.concat(testLogs).join('\n')), | ||
'...'].join('\n')); | ||
} | ||
|
||
function resultString(id, prefix, result, quietLogs) { | ||
var string = resultDisplay(id, prefix, result) + '\n'; | ||
if (result.error || (!quietLogs && result.logs && result.logs.length)) { | ||
string += yamlDisplay(result.error, result.logs) + '\n'; | ||
} | ||
return string; | ||
} | ||
|
||
exports.resultString = resultString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copied from https://github.com/testem/testem/blob/79e75d850942804e197d4bb676b9cbc5c4026b53/lib/reporters/tap_reporter.js | ||
'use strict'; | ||
|
||
var displayutils = require('./displayutils'); | ||
|
||
function TapReporter(silent, out, config) { | ||
this.out = out || process.stdout; | ||
this.silent = silent; | ||
this.quietLogs = !!config.get('tap_quiet_logs'); | ||
this.stoppedOnError = null; | ||
this.id = 1; | ||
this.total = 0; | ||
this.pass = 0; | ||
this.skipped = 0; | ||
this.results = []; | ||
this.errors = []; | ||
this.logs = []; | ||
} | ||
TapReporter.prototype = { | ||
report: function(prefix, data) { | ||
this.results.push({ | ||
launcher: prefix, | ||
result: data | ||
}); | ||
this.display(prefix, data); | ||
this.total++; | ||
if (data.skipped) { | ||
this.skipped++; | ||
} else if (data.passed) { | ||
this.pass++; | ||
} | ||
}, | ||
summaryDisplay: function() { | ||
var lines = [ | ||
'1..' + this.total, | ||
'# tests ' + this.total, | ||
'# pass ' + this.pass, | ||
'# skip ' + this.skipped, | ||
'# fail ' + (this.total - this.pass - this.skipped) | ||
]; | ||
|
||
if (this.pass + this.skipped === this.total) { | ||
lines.push(''); | ||
lines.push('# ok'); | ||
} | ||
return lines.join('\n'); | ||
}, | ||
display: function(prefix, result) { | ||
if (this.silent) { | ||
return; | ||
} | ||
this.out.write(displayutils.resultString(this.id++, prefix, result, this.quietLogs)); | ||
}, | ||
finish: function() { | ||
if (this.silent) { | ||
return; | ||
} | ||
this.out.write('\n' + this.summaryDisplay() + '\n'); | ||
} | ||
}; | ||
|
||
module.exports = TapReporter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
// String padding function adapted from <http://jsfromhell.com/string/pad> | ||
function pad(str, l, s, t) { | ||
var ol = l; | ||
return (s || (s = ' '), (l -= str.length) > 0 ? | ||
(s = new Array(Math.ceil(l / s.length) + 1).join(s)) | ||
.substr(0, t = !t ? l : t === 1 ? 0 : | ||
Math.ceil(l / 2)) + str + s.substr(0, l - t) : str).substring(0, ol); | ||
} | ||
|
||
function indent(text, width) { | ||
return text.split('\n').map(function(line) { | ||
return new Array((width || 4) + 1).join(' ') + line; | ||
}).join('\n'); | ||
} | ||
|
||
function splitLines(text, colLimit) { | ||
if (!text) { | ||
return []; | ||
} | ||
var firstSplit = text.split('\n'); | ||
var secondSplit = []; | ||
firstSplit.forEach(function(line) { | ||
while (line.length > colLimit) { | ||
var first = line.substring(0, colLimit); | ||
secondSplit.push(first); | ||
line = line.substring(colLimit); | ||
} | ||
secondSplit.push(line); | ||
}); | ||
return secondSplit; | ||
} | ||
|
||
// Simple template function. Replaces occurences of "<name>" with param[name] | ||
function template(str, params) { | ||
return !str.replace ? str : str.replace(/<(.+?)>/g, function(unchanged, name) { | ||
return name in params ? params[name] : unchanged; | ||
}); | ||
} | ||
|
||
exports.pad = pad; | ||
exports.indent = indent; | ||
exports.splitLines = splitLines; | ||
exports.template = template; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Ember from 'ember'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Ember.Route.extend({ | ||
export default Route.extend({ | ||
}); |
Oops, something went wrong.