mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) bump mocha version to allow parallel tests; move more tests to core
Summary: This uses a newer version of mocha in grist-core so that tests can be run in parallel. That allows more tests to be moved without slowing things down overall. Tests moved are venerable browser tests; only the ones that "just work" or worked without too much trouble to are moved, in order to keep the diff from growing too large. Will wrestle with more in follow up. Parallelism is at the file level, rather than the individual test. The newer version of mocha isn't needed for grist-saas repo; tests are parallelized in our internal CI by other means. I've chosen to allocate files to workers in a cruder way than our internal CI, based on initial characters rather than an automated process. The automated process would need some reworking to be compatible with mocha running in parallel mode. Test Plan: this diff was tested first on grist-core, then ported to grist-saas so saas repo history will correctly track history of moved files. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D3927
This commit is contained in:
34
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/TestSubscribe.js
vendored
Normal file
34
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/TestSubscribe.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
const grist = require('grist-plugin-api');
|
||||
|
||||
const {foo} = grist.rpc.getStub('foo@grist');
|
||||
let tableId = 'Table1';
|
||||
const colId = 'A';
|
||||
let promise = Promise.resolve(true);
|
||||
|
||||
grist.rpc.on('message', msg => {
|
||||
if (msg.type === "docAction") {
|
||||
if (msg.action[0] === 'RenameTable') {
|
||||
tableId = msg.action[2];
|
||||
}
|
||||
promise = getColValues(colId).then(foo);
|
||||
}
|
||||
});
|
||||
|
||||
function getColValues(colId) {
|
||||
return grist.docApi.fetchTable(tableId).then(data => data[colId]);
|
||||
}
|
||||
|
||||
class TestSubscribe {
|
||||
|
||||
invoke(api, name, args){
|
||||
return grist[api][name](...args);
|
||||
}
|
||||
|
||||
// Returns a promise that resolves when an ongoing call resolves. Resolves right-awa if plugin has
|
||||
// no pending call.
|
||||
waitForPlugin() {
|
||||
return promise.then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TestSubscribe;
|
||||
21
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/main.js
vendored
Normal file
21
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/main.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const grist = require('grist-plugin-api');
|
||||
const TestSubscribe = require('./TestSubscribe');
|
||||
|
||||
grist.rpc.registerImpl("testApiNode", { // todo rename to testGristDocApiNode
|
||||
invoke: (name, args) => {
|
||||
const api = grist.rpc.getStub("GristDocAPI@grist", grist.checkers.GristDocAPI);
|
||||
return api[name](...args)
|
||||
.then((result) => [`node-GristDocAPI ${name}(${args.join(",")})`, result]);
|
||||
},
|
||||
});
|
||||
|
||||
grist.rpc.registerImpl("testDocStorage", {
|
||||
invoke: (name, args) => {
|
||||
const api = grist.rpc.getStub("DocStorage@grist", grist.checkers.Storage);
|
||||
return api[name](...args);
|
||||
},
|
||||
});
|
||||
|
||||
grist.rpc.registerImpl("testSubscribe", new TestSubscribe());
|
||||
|
||||
grist.ready();
|
||||
7
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/manifest.yml
vendored
Normal file
7
test/fixtures/plugins/installedPlugins/plugins/node-GristDocAPI/manifest.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
name: node-GristDocAPI
|
||||
version: 0.0.0
|
||||
description:
|
||||
components:
|
||||
unsafeNode: main.js
|
||||
|
||||
contributions: {}
|
||||
3
test/fixtures/plugins/installedPlugins/plugins/node-fail/main.js
vendored
Normal file
3
test/fixtures/plugins/installedPlugins/plugins/node-fail/main.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
// die immediately.
|
||||
11
test/fixtures/plugins/installedPlugins/plugins/node-fail/manifest.yml
vendored
Normal file
11
test/fixtures/plugins/installedPlugins/plugins/node-fail/manifest.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: node-fail
|
||||
version: 0.0.0
|
||||
description:
|
||||
components:
|
||||
unsafeNode: main.js
|
||||
contributions:
|
||||
fileParsers:
|
||||
- fileExtensions: ["csv"]
|
||||
parseFile:
|
||||
component: unsafeNode
|
||||
name: node-fail
|
||||
11
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/manifest.yml
vendored
Normal file
11
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/manifest.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: minicsv
|
||||
version: 0.0.0
|
||||
description: minicsv
|
||||
components:
|
||||
unsafeNode: nodebox/main.js
|
||||
contributions:
|
||||
fileParsers:
|
||||
- fileExtensions: ["csv"]
|
||||
parseFile:
|
||||
component: unsafeNode
|
||||
name: MiniCSV
|
||||
69
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/main.js
vendored
Normal file
69
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/main.js
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
*
|
||||
* A minimal CSV reader with no type detection.
|
||||
* All communication done by hand - real plugins should have helper code for
|
||||
* RPC.
|
||||
*
|
||||
*/
|
||||
|
||||
const csv = require('csv');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function readCsv(data, replier) {
|
||||
csv.parse(data, {}, function(err, output) {
|
||||
const result = {
|
||||
parseOptions: {
|
||||
options: ""
|
||||
},
|
||||
tables: [
|
||||
{
|
||||
table_name: "space-monkey" + require('dependency_test'),
|
||||
column_metadata: output[0].map(name => {
|
||||
return {
|
||||
id: name,
|
||||
type: 'Text'
|
||||
};
|
||||
}),
|
||||
table_data: output[0].map((name, idx) => {
|
||||
return output.slice(1).map(row => row[idx]);
|
||||
})
|
||||
}
|
||||
]
|
||||
};
|
||||
replier(result);
|
||||
});
|
||||
}
|
||||
|
||||
function processMessage(msg, replier, error_replier) {
|
||||
if (msg.meth == 'parseFile') {
|
||||
var dir = msg.dir;
|
||||
var fname = msg.args[0].path;
|
||||
var data = fs.readFileSync(path.resolve(dir, fname));
|
||||
readCsv(data, replier);
|
||||
} else {
|
||||
error_replier('unknown method');
|
||||
}
|
||||
}
|
||||
|
||||
process.on('message', (m) => {
|
||||
const sendReply = (result) => {
|
||||
process.send({
|
||||
mtype: 2, /* RespData */
|
||||
reqId: m.reqId,
|
||||
data: result
|
||||
});
|
||||
};
|
||||
const sendError = (txt) => {
|
||||
process.send({
|
||||
mtype: 3, /* RespErr */
|
||||
reqId: m.reqId,
|
||||
mesg: txt
|
||||
});
|
||||
};
|
||||
processMessage(m, sendReply, sendError);
|
||||
});
|
||||
|
||||
// Once we have a handler for 'message' set up, send home a ready
|
||||
// message to give the all-clear.
|
||||
process.send({ mtype: 4, data: {ready: true }});
|
||||
3
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/node_modules/dependency_test/index.js
generated
vendored
Normal file
3
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/node_modules/dependency_test/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = 42;
|
||||
11
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/node_modules/dependency_test/package.json
generated
vendored
Normal file
11
test/fixtures/plugins/installedPlugins/plugins/node-mini-csv/nodebox/node_modules/dependency_test/package.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "dependency_test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
3
test/fixtures/plugins/installedPlugins/plugins/node-wrong-message/main.js
vendored
Normal file
3
test/fixtures/plugins/installedPlugins/plugins/node-wrong-message/main.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
process.send({ greeny: true });
|
||||
11
test/fixtures/plugins/installedPlugins/plugins/node-wrong-message/manifest.yml
vendored
Normal file
11
test/fixtures/plugins/installedPlugins/plugins/node-wrong-message/manifest.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: node-wrong-message
|
||||
version: 0.0.0
|
||||
description:
|
||||
components:
|
||||
unsafeNode: main.js
|
||||
contributions:
|
||||
fileParsers:
|
||||
- fileExtensions: ["csv"]
|
||||
parseFile:
|
||||
component: unsafeNode
|
||||
name: node-wrong-message
|
||||
10
test/fixtures/plugins/installedPlugins/plugins/valid-import-source/manifest.yml
vendored
Normal file
10
test/fixtures/plugins/installedPlugins/plugins/valid-import-source/manifest.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
name: validPluginName
|
||||
version: 0.0.1
|
||||
components:
|
||||
safeBrowser: '.'
|
||||
contributions:
|
||||
importSources:
|
||||
- importSource:
|
||||
component: "safeBrowser"
|
||||
name: index.html
|
||||
label: My custom safe importer
|
||||
Reference in New Issue
Block a user