mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Tools: Run all tests in parallel
This commit is contained in:
parent
7644d05225
commit
7d2551c9c3
@ -5,9 +5,9 @@
|
|||||||
"author": "Laurent Cozic",
|
"author": "Laurent Cozic",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --config=jest.config.js --runInBand --bail --forceExit",
|
"test": "jest --config=jest.config.js --bail --forceExit",
|
||||||
"test-one": "jest --verbose=false --config=jest.config.js --runInBand --bail --forceExit",
|
"test-one": "jest --verbose=false --config=jest.config.js --bail --forceExit",
|
||||||
"test-ci": "jest --config=jest.config.js --runInBand --forceExit",
|
"test-ci": "jest --config=jest.config.js --forceExit",
|
||||||
"build": "gulp build",
|
"build": "gulp build",
|
||||||
"start": "gulp build -L && node \"build/main.js\" --stack-trace-enabled --log-level debug --env dev",
|
"start": "gulp build -L && node \"build/main.js\" --stack-trace-enabled --log-level debug --env dev",
|
||||||
"tsc": "node node_modules/typescript/bin/tsc --project tsconfig.json",
|
"tsc": "node node_modules/typescript/bin/tsc --project tsconfig.json",
|
||||||
|
@ -53,6 +53,13 @@ const S3 = require('aws-sdk/clients/s3');
|
|||||||
const { Dirnames } = require('@joplin/lib/services/synchronizer/utils/types');
|
const { Dirnames } = require('@joplin/lib/services/synchronizer/utils/types');
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp');
|
||||||
|
|
||||||
|
// Each suite has its own separate data and temp directory so that multiple
|
||||||
|
// suites can be run at the same time. suiteName is what is used to
|
||||||
|
// differentiate between suite and it is currently set to a random string
|
||||||
|
// (Ideally it would be something like the filename currently being executed by
|
||||||
|
// Jest, to make debugging easier, but it's not clear how to get this info).
|
||||||
|
const suiteName_ = uuid.createNano();
|
||||||
|
|
||||||
const databases_ = [];
|
const databases_ = [];
|
||||||
let synchronizers_ = [];
|
let synchronizers_ = [];
|
||||||
const synchronizerContexts_ = {};
|
const synchronizerContexts_ = {};
|
||||||
@ -89,10 +96,11 @@ EncryptionService.fsDriver_ = fsDriver;
|
|||||||
FileApiDriverLocal.fsDriver_ = fsDriver;
|
FileApiDriverLocal.fsDriver_ = fsDriver;
|
||||||
|
|
||||||
const logDir = `${__dirname}/../tests/logs`;
|
const logDir = `${__dirname}/../tests/logs`;
|
||||||
const baseTempDir = `${__dirname}/../tests/tmp`;
|
const baseTempDir = `${__dirname}/../tests/tmp/${suiteName_}`;
|
||||||
|
const dataDir = `${__dirname}/data/${suiteName_}`;
|
||||||
fs.mkdirpSync(logDir, 0o755);
|
fs.mkdirpSync(logDir, 0o755);
|
||||||
fs.mkdirpSync(baseTempDir, 0o755);
|
fs.mkdirpSync(baseTempDir, 0o755);
|
||||||
fs.mkdirpSync(`${__dirname}/data`);
|
fs.mkdirpSync(dataDir);
|
||||||
|
|
||||||
SyncTargetRegistry.addClass(SyncTargetMemory);
|
SyncTargetRegistry.addClass(SyncTargetMemory);
|
||||||
SyncTargetRegistry.addClass(SyncTargetFilesystem);
|
SyncTargetRegistry.addClass(SyncTargetFilesystem);
|
||||||
@ -139,12 +147,12 @@ const syncDir = `${__dirname}/../tests/sync`;
|
|||||||
|
|
||||||
const dbLogger = new Logger();
|
const dbLogger = new Logger();
|
||||||
dbLogger.addTarget('console');
|
dbLogger.addTarget('console');
|
||||||
dbLogger.addTarget('file', { path: `${logDir}/log.txt` });
|
// dbLogger.addTarget('file', { path: `${logDir}/log.txt` });
|
||||||
dbLogger.setLevel(Logger.LEVEL_WARN);
|
dbLogger.setLevel(Logger.LEVEL_WARN);
|
||||||
|
|
||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
logger.addTarget('console');
|
logger.addTarget('console');
|
||||||
logger.addTarget('file', { path: `${logDir}/log.txt` });
|
// logger.addTarget('file', { path: `${logDir}/log.txt` });
|
||||||
logger.setLevel(Logger.LEVEL_WARN); // Set to DEBUG to display sync process in console
|
logger.setLevel(Logger.LEVEL_WARN); // Set to DEBUG to display sync process in console
|
||||||
|
|
||||||
Logger.initializeGlobalLogger(logger);
|
Logger.initializeGlobalLogger(logger);
|
||||||
@ -269,7 +277,7 @@ async function setupDatabase(id = null, options = null) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = `${__dirname}/data/test-${id}.sqlite`;
|
const filePath = `${dataDir}/test-${id}.sqlite`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.unlink(filePath);
|
await fs.unlink(filePath);
|
||||||
@ -292,15 +300,15 @@ function resourceDirName(id = null) {
|
|||||||
|
|
||||||
function resourceDir(id = null) {
|
function resourceDir(id = null) {
|
||||||
if (id === null) id = currentClient_;
|
if (id === null) id = currentClient_;
|
||||||
return `${__dirname}/data/${resourceDirName(id)}`;
|
return `${dataDir}/${resourceDirName(id)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pluginDir(id = null) {
|
function pluginDir(id = null) {
|
||||||
if (id === null) id = currentClient_;
|
if (id === null) id = currentClient_;
|
||||||
return `${__dirname}/data/plugins-${id}`;
|
return `${dataDir}/plugins-${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupDatabaseAndSynchronizer(id = null, options = null) {
|
async function setupDatabaseAndSynchronizer(id, options = null) {
|
||||||
if (id === null) id = currentClient_;
|
if (id === null) id = currentClient_;
|
||||||
|
|
||||||
BaseService.logger_ = logger;
|
BaseService.logger_ = logger;
|
||||||
|
Loading…
Reference in New Issue
Block a user