(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:
Paul Fitzpatrick
2023-06-27 02:11:08 -04:00
parent 7d3b4b49d5
commit bcbf57d590
126 changed files with 6833 additions and 759 deletions

View File

@@ -0,0 +1,3 @@
version: 0.0.1
contributions:
importSources:

View File

@@ -0,0 +1,12 @@
name: crazy-plugin
version: 0.0.1
experimental: true
components:
safePython: sandbox/main.py
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1 @@
# nothing

View File

@@ -0,0 +1,3 @@
version: 0.0.1
contributions:
invalidContibutionPoint:

View File

@@ -0,0 +1,14 @@
name: pluginName
version: 0.0.1
components:
safePython: sandbox/main.py
deactivate:
# Let's keep it low for tests to be fast, but big enough for test to be accurate.
inactivitySec: 0.1
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1,28 @@
import time
import sandbox
# pylint: disable=unused-argument
# pylint: disable=no-member
def import_files(file_source, parse_options):
end = time.time() + 1
while time.time() < end:
pass
return {
"parseOptions": {},
# Make sure the output is a list of GristTables as documented at app/plugin/GristTable.ts
"tables": [{
"table_name": "mytable",
"column_metadata": [],
"table_data": [],
}]
}
def main():
sandbox.register("csv_parser.parseFile", import_files)
sandbox.run() # pylint: disable=no-member
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,9 @@
name: missing-components
version: 0.0.1
# missing `components` entry
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1,10 @@
name: missing-safePython
version: 0.0.1
components:
# missing `safePython` component
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1,14 @@
name: pluginName
version: 0.0.1
components:
safePython: sandbox/main.py
deactivate:
# Let's keep it low for tests to be fast, but big enough for test to be accurate.
inactivitySec: 0.1
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1,28 @@
import sandbox
# pylint: disable=unused-argument
# pylint: disable=no-member
# TODO: configure pylint behavior for both `test/fixtures/plugins` and
# `/plugins` folders: either to ignore them completely or to ignore
# above mentioned rules.
def import_files(file_source, parse_options=None):
return {
"parseOptions": {},
"tables": [{
"table_name": "mytable",
"column_metadata": [],
"table_data": []
}]}
def main():
# Todo: Grist should expose a register method accepting arguments as
# follow: register('csv_parser', 'importFiles', can_parse)
sandbox.register("csv_parser.parseFile", import_files)
sandbox.run() # pylint: disable=no-member
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,5 @@
const grist = require('grist-plugin-api');
grist.rpc.registerFunc("yo", (name) => `yo ${name}`);
grist.rpc.registerFunc("yoSafePython", (name) => grist.rpc.callRemoteFunc("yo@sandbox/main.py", name));
grist.ready();

View File

@@ -0,0 +1,17 @@
name: testPluginFunction
version: 0.0.1
components:
safePython: sandbox/main.py
unsafeNode: backend.js
safeBrowser: main.js
# For the purpose of this unit-test contributions property is actually
# NOT need and only provided for the sake of making this manifest
# valid,
contributions:
importSources:
- importSource:
component: "safeBrowser"
name: index.html
label: My safe importer

View File

@@ -0,0 +1,15 @@
import sandbox
def greet(name):
return "Hi " + name
def yo(name):
return "yo " + name + " from safePython"
def main():
sandbox.register("greet", greet)
sandbox.register("yo", yo)
sandbox.run()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,11 @@
name: pluginName
version: 0.0.1
components:
safePython: sandbox/main.py
contributions:
fileParsers:
- fileExtensions: ["csv"]
parseFile:
component: "safePython"
name: "csv_parser"

View File

@@ -0,0 +1,29 @@
import sandbox
# pylint: disable=unused-argument
# pylint: disable=no-member
# TODO: configure pylint behavior for both `test/fixtures/plugins` and
# `/plugins` folders: either to ignore them completely or to ignore
# above mentioned rules.
def import_files(file_source, parse_options):
parse_options.update({"NUM_ROWS" : 1})
return {
"parseOptions": parse_options,
"tables": [{
"table_name": "mytable",
"column_metadata": [],
"table_data": []
}]}
def main():
# Todo: Grist should expose a register method accepting arguments as
# follow: register('csv_parser', 'parseFile', can_parse)
sandbox.register("csv_parser.parseFile", import_files)
sandbox.run() # pylint: disable=no-member
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,10 @@
name: pluginName
version: 0.0.1
components:
safeBrowser: '.'
contributions:
importSources:
- importSource:
component: "safeBrowser"
name: index.html
label: My safe importer

View File

@@ -0,0 +1 @@
wrong manifest as well in json

View File

@@ -0,0 +1 @@
:some-wrong-manifest