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
5
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/duration.js
Executable file
5
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/duration.js
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
test('duration', function(done) {
|
||||
setTimeout(done, 100, null);
|
||||
});
|
||||
|
||||
7
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/fail.js
Executable file
7
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/fail.js
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
test('fail', function() {
|
||||
throw new Error('myerror');
|
||||
});
|
||||
|
||||
test('pass later', function() {
|
||||
});
|
||||
0
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/pass.js
Executable file
0
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/pass.js
Executable file
1
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/pending.js
Executable file
1
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/examples/pending.js
Executable file
|
|
@ -0,0 +1 @@
|
|||
test.skip('pending');
|
||||
1
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/index.js
Executable file
1
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/index.js
Executable file
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('./lib/tbpl');
|
||||
164
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/lib/tbpl.js
Executable file
164
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/lib/tbpl.js
Executable file
|
|
@ -0,0 +1,164 @@
|
|||
'use strict';
|
||||
var Base = require('mocha').reporters.Base;
|
||||
var fsPath = require('path');
|
||||
|
||||
/**
|
||||
* Initialize a new TBPL reporter.
|
||||
* @constructor
|
||||
* @param {Runner} runner mocha test runner.
|
||||
*/
|
||||
function TBPL(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
this.onEnd = this.onEnd.bind(this);
|
||||
runner.on('end', this.onEnd);
|
||||
this.onFail = this.onFail.bind(this);
|
||||
runner.on('fail', this.onFail);
|
||||
this.onPass = this.onPass.bind(this);
|
||||
runner.on('pass', this.onPass);
|
||||
this.onPending = this.onPending.bind(this);
|
||||
runner.on('pending', this.onPending);
|
||||
this.onTest = this.onTest.bind(this);
|
||||
runner.on('test', this.onTest);
|
||||
this.onTestEnd = this.onTestEnd.bind(this);
|
||||
runner.on('test end', this.onTestEnd);
|
||||
|
||||
this.failing = 0;
|
||||
this.passing = 0;
|
||||
this.pending = 0;
|
||||
}
|
||||
module.exports = TBPL;
|
||||
|
||||
|
||||
TBPL.prototype = {
|
||||
__proto__: Base.prototype,
|
||||
|
||||
/**
|
||||
* Number of failing tests.
|
||||
* @type {number}
|
||||
*/
|
||||
failing: 0,
|
||||
|
||||
/**
|
||||
* Number of passing tests.
|
||||
* @type {number}
|
||||
*/
|
||||
passing: 0,
|
||||
|
||||
/**
|
||||
* Number of pending tests.
|
||||
* @type {number}
|
||||
*/
|
||||
pending: 0,
|
||||
|
||||
/**
|
||||
* Output a summary of the mocha run.
|
||||
*/
|
||||
onEnd: function() {
|
||||
console.log('*~*~* Results *~*~*');
|
||||
console.log('passed: %d', this.passing);
|
||||
console.log('failed: %d', this.failing);
|
||||
console.log('todo: %d', this.pending);
|
||||
this.epilogue();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test failing test.
|
||||
* @param {Error} err failure.
|
||||
*/
|
||||
onFail: function(test, err) {
|
||||
var title = this.getTitle(test),
|
||||
file = this.getFile(test);
|
||||
console.log('TEST-UNEXPECTED-FAIL | %s | %s', file, title);
|
||||
console.log(err.stack);
|
||||
this.failing += 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test passing test.
|
||||
*/
|
||||
onPass: function(test) {
|
||||
var title = this.getTitle(test),
|
||||
file = this.getFile(test);
|
||||
console.log('TEST-PASS | %s | %s', file, title);
|
||||
this.passing += 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test pending test.
|
||||
*/
|
||||
onPending: function(test) {
|
||||
var title = this.getTitle(test),
|
||||
file = this.getFile(test);
|
||||
console.log('TEST-PENDING | %s | %s', file, title);
|
||||
this.pending += 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test started test.
|
||||
*/
|
||||
onTest: function(test) {
|
||||
var title = this.getTitle(test),
|
||||
file = this.getFile(test);
|
||||
console.log('TEST-START | %s | %s', file, title);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test finished test.
|
||||
*/
|
||||
onTestEnd: function(test) {
|
||||
var title = this.getTitle(test),
|
||||
file = this.getFile(test);
|
||||
console.log('TEST-END | %s | %s took %d ms', file, title, test.duration);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Test} test some test.
|
||||
* @return {string} the title of the test.
|
||||
*/
|
||||
getTitle: function(test) {
|
||||
return this.sanitize(test.fullTitle());
|
||||
},
|
||||
|
||||
getFile: function(test) {
|
||||
var file = null;
|
||||
if ('file' in test) {
|
||||
file = test.file;
|
||||
}
|
||||
|
||||
if ('parent' in test) {
|
||||
var tmpfile = this.getFile(test.parent);
|
||||
if (tmpfile) {
|
||||
file = tmpfile;
|
||||
}
|
||||
}
|
||||
|
||||
// Make the file relative if we have one...
|
||||
if (file) {
|
||||
// Resolve ensures we never end up with two trailing slashes...
|
||||
var pwd = fsPath.resolve(process.cwd()) + '/';
|
||||
// Make sure the file starts with pwd before replacing it.
|
||||
if (file.indexOf(pwd) === 0) {
|
||||
file = file.replace(pwd, '');
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} str some string that could potentially have character
|
||||
* sequences that tbpl would understand.
|
||||
* @return {string} sanitized string.
|
||||
*/
|
||||
sanitize: function(str) {
|
||||
// These are controversial words and we must censor them!
|
||||
return str
|
||||
.replace(/PROCESS-CRASH/g, '*************')
|
||||
.replace(/TEST-END/g, '********')
|
||||
.replace(/TEST-KNOWN-FAIL/g, '***************')
|
||||
.replace(/TEST-PASS/g, '*********')
|
||||
.replace(/TEST-START/g, '***********')
|
||||
.replace(/TEST-UNEXPECTED-FAIL/g, '********************');
|
||||
}
|
||||
};
|
||||
14
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/package.json
Executable file
14
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/package.json
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "mocha-tbpl-reporter",
|
||||
"version": "0.2.1",
|
||||
"author": "The Gaia Team <dev-gaia@lists.mozilla.org>",
|
||||
"description": "Mocha reporter for TBPL (tinderboxpushlog)",
|
||||
|
||||
"devDependencies": {
|
||||
"mocha": "^1.0.0"
|
||||
},
|
||||
|
||||
"peerDependencies": {
|
||||
"mocha": ">=1.0"
|
||||
}
|
||||
}
|
||||
166
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/test/tbpl_test.js
Executable file
166
gaia/tests/jsmarionette/mocha/mocha-tbpl-reporter/test/tbpl_test.js
Executable file
|
|
@ -0,0 +1,166 @@
|
|||
'use strict';
|
||||
var TBPL = require('../lib/tbpl'),
|
||||
assert = require('assert'),
|
||||
sinon = require('sinon');
|
||||
|
||||
suite('TBPL', function() {
|
||||
var subject, runner, on, log;
|
||||
|
||||
setup(function() {
|
||||
runner = {
|
||||
on: function(type, listener) {}
|
||||
};
|
||||
|
||||
on = sinon.spy(runner, 'on');
|
||||
log = sinon.spy(console, 'log');
|
||||
subject = new TBPL(runner);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
on.restore();
|
||||
log.restore();
|
||||
});
|
||||
|
||||
test('#constructor', function() {
|
||||
sinon.assert.calledWith(on, 'end');
|
||||
sinon.assert.calledWith(on, 'fail');
|
||||
sinon.assert.calledWith(on, 'pass');
|
||||
sinon.assert.calledWith(on, 'pending');
|
||||
sinon.assert.calledWith(on, 'test');
|
||||
sinon.assert.calledWith(on, 'test end');
|
||||
assert.strictEqual(subject.failing, 0);
|
||||
assert.strictEqual(subject.passing, 0);
|
||||
assert.strictEqual(subject.pending, 0);
|
||||
});
|
||||
|
||||
test('#onEnd', function() {
|
||||
subject.onEnd();
|
||||
assert.ok(log.calledWith('*~*~* Results *~*~*'));
|
||||
assert.ok(log.calledWith('passed: %d', 0));
|
||||
assert.ok(log.calledWith('failed: %d', 0));
|
||||
assert.ok(log.calledWith('todo: %d', 0));
|
||||
});
|
||||
|
||||
test('#onFail', function() {
|
||||
var failing = subject.failing;
|
||||
var file = 'doge_such_broke_test.js';
|
||||
var err = new Error('xfoo');
|
||||
subject.onFail(
|
||||
{
|
||||
file: file,
|
||||
fullTitle: function() {
|
||||
return 'some title';
|
||||
}
|
||||
},
|
||||
err
|
||||
);
|
||||
|
||||
assert.strictEqual(subject.failing, failing + 1);
|
||||
assert.ok(log.calledWith(
|
||||
'TEST-UNEXPECTED-FAIL | %s | %s',
|
||||
file,
|
||||
'some title'
|
||||
));
|
||||
assert.ok(log.calledWith(err.stack));
|
||||
});
|
||||
|
||||
test('#onPass', function() {
|
||||
var passing = subject.passing;
|
||||
subject.onPass({
|
||||
file: 'file.js',
|
||||
fullTitle: function() {
|
||||
return 'some title';
|
||||
}
|
||||
});
|
||||
|
||||
assert.strictEqual(subject.passing, passing + 1);
|
||||
assert.ok(log.calledWith('TEST-PASS | %s | %s', 'file.js', 'some title'));
|
||||
});
|
||||
|
||||
test('#onPending', function() {
|
||||
var pending = subject.pending;
|
||||
subject.onPending({
|
||||
file: 'file.js',
|
||||
fullTitle: function() {
|
||||
return 'some title';
|
||||
}
|
||||
});
|
||||
|
||||
assert.strictEqual(subject.pending, pending + 1);
|
||||
assert.ok(
|
||||
log.calledWith('TEST-PENDING | %s | %s', 'file.js', 'some title')
|
||||
);
|
||||
});
|
||||
|
||||
test('#onTest', function() {
|
||||
subject.onTest({
|
||||
file: 'file.js',
|
||||
fullTitle: function() {
|
||||
return 'some title';
|
||||
}
|
||||
});
|
||||
|
||||
assert.ok(log.calledWith('TEST-START | %s | %s', 'file.js', 'some title'));
|
||||
});
|
||||
|
||||
test('#onTestEnd', function() {
|
||||
subject.onTestEnd({
|
||||
duration: 100,
|
||||
file: 'file.js',
|
||||
fullTitle: function() {
|
||||
return 'some title';
|
||||
}
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
log.calledWith(
|
||||
'TEST-END | %s | %s took %d ms', 'file.js', 'some title', 100
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('#getFile - relative', function() {
|
||||
var file = subject.getFile({
|
||||
file: __dirname + '/xfoo'
|
||||
});
|
||||
assert.equal(
|
||||
file,
|
||||
'node_modules/mocha-tbpl-reporter/test/xfoo'
|
||||
);
|
||||
});
|
||||
|
||||
test('#getFile - relative different pwd', function() {
|
||||
var file = subject.getFile({
|
||||
file: 'woot/bar.js'
|
||||
});
|
||||
assert.equal(file, 'woot/bar.js');
|
||||
});
|
||||
|
||||
test('#getFile - absolute', function() {
|
||||
var file = subject.getFile({
|
||||
file: '/magic/foo/bar/file.js'
|
||||
});
|
||||
assert.equal(file, '/magic/foo/bar/file.js');
|
||||
});
|
||||
|
||||
test('#getTitle', function() {
|
||||
var result = subject.getTitle({
|
||||
fullTitle: function() {
|
||||
return 'some title TEST-END';
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(result, 'some title ********');
|
||||
});
|
||||
|
||||
test('#sanitize', function() {
|
||||
var str = 'Fuzzy PROCESS-CRASH was a TEST-END, ' +
|
||||
'fuzzy TEST-KNOWN-FAIL had no TEST-PASS, ' +
|
||||
'fuzzy TEST-START wasn\'t TEST-UNEXPECTED-FAIL was he?';
|
||||
var result = subject.sanitize(str);
|
||||
assert.equal(result,
|
||||
'Fuzzy ************* was a ********, ' +
|
||||
'fuzzy *************** had no *********, ' +
|
||||
'fuzzy *********** wasn\'t ******************** was he?');
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue