Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
81
gaia/tests/reporters/jsonmoztest.js
Executable file
81
gaia/tests/reporters/jsonmoztest.js
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* Initialize a new `JSON` reporter for MozTest.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
/* global global */
|
||||
|
||||
module.exports = JSONMozTestReporter;
|
||||
|
||||
function JSONMozTestReporter(runner) {
|
||||
var self = this;
|
||||
global.Mocha.reporters.Base.call(this, runner);
|
||||
|
||||
var tests = [];
|
||||
var failures = [];
|
||||
var passes = [];
|
||||
|
||||
runner.on('test end', function(test) {
|
||||
tests.push(test);
|
||||
});
|
||||
|
||||
runner.on('pass', function(test) {
|
||||
passes.push(test);
|
||||
});
|
||||
|
||||
runner.on('fail', function(test) {
|
||||
failures.push(test);
|
||||
});
|
||||
|
||||
runner.on('end', function() {
|
||||
var obj = {
|
||||
stats: self.stats,
|
||||
tests: tests.map(clean),
|
||||
failures: failures.map(cleanErr),
|
||||
passes: passes.map(clean)
|
||||
};
|
||||
|
||||
process.stdout.write(JSON.stringify(obj, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a plain-object representation of `test`
|
||||
* free of cyclic properties etc.
|
||||
*
|
||||
* @param {Object} test
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clean(test) {
|
||||
return {
|
||||
title: test.title,
|
||||
fullTitle: test.fullTitle(),
|
||||
duration: test.duration
|
||||
};
|
||||
}
|
||||
|
||||
function cleanErr(test) {
|
||||
var err = test.err;
|
||||
var message = err.message || '';
|
||||
var stack = window.xpcError.format(err);
|
||||
var index = stack.indexOf(message) + message.length;
|
||||
var msg = stack.slice(0, index);
|
||||
var actual = err.actual;
|
||||
var expected = err.expected;
|
||||
|
||||
return {
|
||||
title: test.title,
|
||||
fullTitle: test.fullTitle(),
|
||||
duration: test.duration,
|
||||
stack: stack,
|
||||
index: index,
|
||||
msg: msg,
|
||||
actual: actual,
|
||||
expected: expected
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue