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:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,23 @@
/* global forkFixture */
'use strict';
var Consumer = require('../../consumer');
var Mocha = require('mocha');
suite('reporter', function() {
function testReporter(reporterType) {
suite(reporterType, function() {
['pass', 'fail', 'pending'].forEach(function(testType) {
test(test, function(done) {
var child = forkFixture(testType);
var runner = new Consumer(child);
/* jshint nonew: false */
new Mocha.reporters[reporterType](runner);
/* jshint nonew: true */
runner.once('end', done);
});
});
});
}
['Dot', 'Spec'].forEach(testReporter);
});

View file

@ -0,0 +1,46 @@
/* global assert, forkFixture */
'use strict';
suite('reporter', function() {
var msgs = [];
var child;
setup(function(done) {
this.timeout('10s');
child = forkFixture('pass');
child.on('message', function(content) {
if (Array.isArray(content) && content[0] === 'mocha-proxy') {
var msg = content[1];
msgs.push(msg[0]);
if (msg[0] === 'end') {
return done();
}
}
});
});
test('got messages', function() {
var expectedMsgs = [
'start',
'suite',
'suite',
'test',
'pass',
'test end',
'test',
'pass',
'test end',
'suite end',
'suite',
'test',
'pass',
'test end',
'suite end',
'suite end',
'end'
];
assert.deepEqual(msgs, expectedMsgs);
});
});

View file

@ -0,0 +1,150 @@
/* global forkFixture */
'use strict';
var assert = require('assert');
suite('consumer', function() {
var child;
var Consumer = require('../consumer');
var subject;
var EVENTS = [
'start',
'pass',
'test',
'test end',
'suite',
'suite end',
'end'
];
var emitted;
setup(function(done) {
emitted = {};
child = forkFixture('pass');
subject = new Consumer(child);
EVENTS.forEach(function(event) {
emitted = {};
subject.on(event, function() {
if (!emitted[event]) {
emitted[event] = [];
}
emitted[event].push(Array.prototype.slice.call(arguments));
});
});
subject.once('end', done);
});
function emitsRunnable(event) {
if (typeof event === 'string') {
return emitted[event].forEach(emitsRunnable);
}
assert.ok(typeof event[0].slow === 'function', 'has .slow');
assert.equal(event[0].slow(), event[0]._slow);
assert.ok(typeof event[0].fullTitle === 'function', 'has .fullTitle()');
if (event[0].parent && event[0].parent.fullTitle()) {
assert.equal(
event[0].fullTitle(),
event[0].parent.fullTitle() + ' ' + event[0].title
);
} else {
assert.equal(
event[0].fullTitle(),
event[0].title
);
}
}
test('.suite', function() {
assert.ok(subject.suite);
assert.ok(subject.suite.root);
});
suite('suite', function() {
test('is runnable', function() {
emitsRunnable('suite');
});
test('child suite should have reference to parent', function() {
var parent = emitted.suite[0][0];
var child1 = emitted.suite[1][0];
var child2 = emitted.suite[2][0];
assert.ok(!parent.parent, 'root suite has no parent');
assert.strictEqual(
child1.parent,
parent,
'first child references parent'
);
assert.strictEqual(
child2.parent,
parent,
'second child references parent'
);
});
});
test('suite end', function() {
emitsRunnable('suite end');
});
test('test', function() {
emitsRunnable('test');
});
test('pass', function() {
emitsRunnable('pass');
});
test('test end', function() {
emitsRunnable('test end');
});
suite('objects with ._ids are the same', function() {
var tests;
var suites;
function group(events, target) {
events.forEach(function(event) {
emitted[event].forEach(function(items) {
items.forEach(function(item) {
if (!target[item.title]) {
target[item.title] = [];
}
target[item.title].push(item);
});
});
});
}
setup(function() {
tests = {};
suites = {};
group(['test', 'pass', 'test end'], tests);
group(['suite', 'suite end'], suites);
});
test('tests async', function() {
var test = tests.async[0];
tests.async.forEach(function(item) {
assert.strictEqual(test, item);
});
});
test('suite', function() {
var suite = suites.pass[0];
suites.pass.forEach(function(item) {
assert.strictEqual(suite, item);
});
});
});
});

View file

@ -0,0 +1,17 @@
'use strict';
suite('fail', function() {
test('sync', function() {
throw new Error('sync');
});
test('async', function(done) {
done(new Error('async'));
});
test('uncaught', function() {
process.nextTick(function() {
throw new Error('woot');
});
});
});

View file

@ -0,0 +1,8 @@
'use strict';
suite('pass', function() {
test('sync', function() {});
test('async', function(done) { process.nextTick(done); });
});
suite('pass 2', function() {
test('sync 2', function() {});
});

View file

@ -0,0 +1,4 @@
'use strict';
suite('pending', function() {
test('mepending');
});

View file

@ -0,0 +1,9 @@
'use strict';
suite('a', function() {
suite('b', function() {
suite('c', function() {
test('done', function() {
});
});
});
});

View file

@ -0,0 +1,63 @@
'use strict';
var exec = require('child_process').exec,
fork = require('child_process').fork,
EE = require('events').EventEmitter,
debug = require('debug')('mocha-json-proxy:test');
function forkFixture(test) {
var reporterPath = __dirname + '/../reporter.js';
var exec = __dirname + '/../../../../.bin/_mocha';
var cmd = [
'--reporter', reporterPath,
'--ui', 'tdd',
__dirname + '/fixtures/' + test
];
var env = {};
for (var key in process.env) {
env[key] = process.env[key];
}
var runnerOpts = {
env: env
};
// turn on the option to send messages directly between processes.
runnerOpts.env[require(reporterPath).FORK_ENV] = true;
return fork(exec, cmd, runnerOpts);
}
function runFixture(test, callback) {
var cmd =
__dirname + '/../../../../.bin/mocha' +
' --ui tdd --reporter ' + __dirname + '/../reporter ' +
__dirname + '/fixtures/' + test;
var emitter = new EE();
exec(cmd, function(err, stdout, stderr) {
debug('stdout', stdout);
if (stderr) {
console.error('ERR>>', stderr);
}
callback(null, emitter);
var out = stdout.trim().split('\n');
out.forEach(function(line) {
var json;
try {
json = JSON.parse(line);
} catch (e) {
console.error(e);
}
emitter.emit.apply(emitter, json);
});
emitter.emit('helper end');
});
}
global.assert = require('chai').assert;
global.runFixture = runFixture;
global.forkFixture = forkFixture;

View file

@ -0,0 +1,232 @@
/* global runFixture */
'use strict';
var assert = require('assert');
suite('reporter', function() {
function event(input, callback) {
var file, type;
if (typeof input === 'string') {
file = type = input;
}
if (typeof input === 'object') {
file = input[0];
type = input[1];
}
return test('event: ' + type, function(done) {
runFixture(file, function(err, emit) {
if (err) {
return done(err);
}
callback(emit, done);
});
});
}
function isTest(input, obj) {
assert.ok(input.fn.indexOf('function') !== -1, 'has function');
assert.ok(input.title);
assert.equal(input.type, 'test');
assert.ok(input._slow);
assert.ok(input._id, 'has _id');
if (obj) {
for (var key in obj) {
assert.equal(input[key], obj[key], key);
}
}
}
function aggregateAll(events, emitter) {
var result = {};
function add(event, data, err) {
if (err)
data.eventErr = err;
if (!result[data.title]) {
result[data.title] = [];
}
result[data.title].push(data);
}
events.forEach(function(event) {
emitter.on(event, add.bind(null, event));
});
return result;
}
function aggregate(event, emitter) {
var result = {};
emitter.on(event, function(data, err) {
// copy the err property if available.
if (err)
data.sentErr = err;
result[data.title] = data;
});
return result;
}
function isError(err, msg) {
if (msg)
assert.ok(err.msg.matches(msg), 'matches msg');
assert.ok(err.stack, 'err.stack');
}
function testIdsMatch(list) {
// usually a test event.
var firstEvent = list[list.length - 1];
// verify the id is valid
assert.ok(firstEvent._id, 'has an _id');
var id = firstEvent._id;
// verify each id matches the other ids.
list.forEach(function(item) {
assert.equal(item._id, id);
});
}
['test', 'test end'].forEach(function(eventName) {
event(['fail', eventName], function(emit, done) {
var testEnd = aggregate(eventName, emit);
emit.on('helper end', function() {
assert.ok(!testEnd.sync.err, 'err is not set');
assert.ok(!testEnd.async.err, 'err is not set');
isTest(testEnd.sync);
isTest(testEnd.async);
done();
});
});
});
suite('fail', function() {
event('fail', function(emit, done) {
var fails = aggregate('fail', emit);
emit.on('helper end', function() {
isTest(fails.sync, { state: 'failed' });
isTest(fails.async, { state: 'failed' });
assert.ok(fails.sync.sentErr, 'sync has err');
assert.ok(fails.async.sentErr, 'async has err');
isError(fails.sync.sentErr);
isError(fails.async.sentErr);
done();
});
});
event(['fail', 'ids'], function(emit, done) {
var results =
aggregateAll(['test', 'test end', 'fail'], emit);
emit.once('helper end', function() {
testIdsMatch(results.sync);
testIdsMatch(results.async);
done();
});
});
});
suite('pass', function() {
event('pass', function(emit, done) {
var passed = aggregate('pass', emit);
emit.on('helper end', function() {
assert.ok(passed.sync, 'sync test');
assert.ok(passed.async, 'async test');
isTest(passed.sync, { state: 'passed' });
isTest(passed.async, { state: 'passed' });
done();
});
});
event(['pass', 'ids'], function(emit, done) {
var results =
aggregateAll(['test', 'test end', 'pass'], emit);
emit.once('helper end', function() {
testIdsMatch(results.sync);
testIdsMatch(results.async);
done();
});
});
});
suite('pending', function() {
event('pending', function(emit, done) {
emit.once('pending', function(data) {
assert.equal(data.title, 'mepending', 'title');
assert.ok(data.pending, 'pending');
done();
});
});
event(['pending', 'ids'], function(emit, done) {
var results =
aggregateAll(['test end', 'pending'], emit);
emit.once('helper end', function() {
testIdsMatch(results.mepending);
done();
});
});
});
/* TODO(gaye): Re-enable these...
event('start', function(emit, done) {
emit.once('start', function() {
done();
});
});
event('end', function(emit, done) {
emit.once('end', function(data) {
done();
});
});
*/
event(['suites', 'suite (end)'], function(emit, done) {
var events = [];
var expected = [
['start', '', 1],
['start', 'a', 2],
['start', 'b', 3],
['start', 'c', 4],
['end', 'c', 4],
['end', 'b', 3],
['end', 'a', 2],
['end', '', 1]
];
function add(type, data) {
events.push([type, data.title, data._id]);
}
emit.on('suite', add.bind(null, 'start'));
emit.on('suite end', add.bind(null, 'end'));
emit.once('helper end', function() {
assert.deepEqual(events, expected);
done();
});
});
});