impress
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -18,2 +18,3 @@ 'use strict'; | ||
const WORKER_PATH = path.join(__dirname, 'lib/worker.js'); | ||
const REPORTER_PATH = path.join(__dirname, 'lib/reporter.js'); | ||
const LOG_PATH = path.join(PATH, 'log'); | ||
@@ -57,3 +58,4 @@ const CTRL_C = 3; | ||
const workerData = { id, kind, root: app.root, path: app.path, port }; | ||
const options = { trackUnmanagedFds: true, workerData }; | ||
const execArgv = [...process.execArgv, `--test-reporter=${REPORTER_PATH}`]; | ||
const options = { trackUnmanagedFds: true, workerData, execArgv }; | ||
const worker = new Worker(WORKER_PATH, options); | ||
@@ -108,4 +110,4 @@ if (kind === 'worker') { | ||
terminate: () => { | ||
process.emit('TERMINATE'); | ||
terminate: (msg) => { | ||
process.emit('TERMINATE', msg.code); | ||
}, | ||
@@ -189,3 +191,3 @@ }; | ||
const stop = async () => { | ||
const stop = async (code = 0) => { | ||
const portsClosed = new Promise((resolve) => { | ||
@@ -206,3 +208,3 @@ impress.console.info('Graceful shutdown in worker 0'); | ||
await portsClosed; | ||
exit('Application server stopped', 0); | ||
exit('Application server stopped', code); | ||
}; | ||
@@ -209,0 +211,0 @@ |
@@ -48,2 +48,3 @@ 'use strict'; | ||
const ERR_TEST = 'Application tests failed'; | ||
const TEST_DELAY = 100; | ||
@@ -58,2 +59,4 @@ class Application extends EventEmitter { | ||
this.path = workerData.path; | ||
this.test = { passed: 0, failed: 0 }; | ||
this.mode = process.env.MODE || 'prod'; | ||
@@ -79,3 +82,2 @@ this.schemas = new Schemas('schemas', this); | ||
this.server = null; | ||
this.mode = process.env.MODE || 'prod'; | ||
} | ||
@@ -142,13 +144,22 @@ | ||
sandbox.application.emit('started'); | ||
if (mode === 'test' && threadId === 1) this.test(); | ||
if (mode === 'test' && threadId === 1) this.runTests(); | ||
} | ||
test() { | ||
this.parallel( | ||
this.tests.map((test) => | ||
node.test(test.name, (t) => this.execute(test.run, t)), | ||
), | ||
ERR_TEST, | ||
).then(() => { | ||
wt.parentPort.postMessage({ name: 'terminate' }); | ||
runTests() { | ||
const { test, tests, config, console } = this; | ||
const timer = setTimeout(() => { | ||
console.error('🔴 Test execution timed out'); | ||
wt.parentPort.postMessage({ name: 'terminate', code: 1 }); | ||
}, config.server.timeouts.test); | ||
const cases = tests.map((t) => node.test(t.name, t.run)); | ||
this.parallel(cases, ERR_TEST).then(() => { | ||
clearTimeout(timer); | ||
setTimeout(() => { | ||
const { passed, failed } = test; | ||
const msg = `Passed ${passed}, Failed: ${failed}`; | ||
if (failed > 0) console.error('🔴 ' + msg); | ||
else console.debug('🟢 ' + msg); | ||
const code = failed === 0 ? 0 : 1; | ||
wt.parentPort.postMessage({ name: 'terminate', code }); | ||
}, TEST_DELAY); | ||
}); | ||
@@ -155,0 +166,0 @@ } |
{ | ||
"name": "impress", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -65,8 +65,8 @@ "description": "Enterprise application server for Node.js", | ||
"dependencies": { | ||
"metacom": "^3.1.0", | ||
"metacom": "^3.1.1", | ||
"metaconfiguration": "^2.1.11", | ||
"metalog": "^3.1.12", | ||
"metaschema": "^2.1.5", | ||
"metautil": "^3.13.0", | ||
"metavm": "^1.2.6", | ||
"metautil": "^3.14.0", | ||
"metavm": "^1.3.0", | ||
"metawatch": "^1.1.1" | ||
@@ -73,0 +73,0 @@ }, |
@@ -99,5 +99,5 @@ <div align="center"> | ||
- Node.js v16.0.0 or later (v18 preferred) | ||
- Linux (tested on Fedora 36, 37, Ubuntu 18, 20 and 22, CentOS 7, 8, 9) | ||
- Postgresql 11 or later (v14 preferred) | ||
- Node.js v18.x or v20.x | ||
- Linux (tested on Fedora v36-38, Ubuntu v18-23, CentOS v7-9) | ||
- Postgresql v11-16 | ||
- OpenSSL v3 or later (optional, for https & wss) | ||
@@ -104,0 +104,0 @@ - [certbot](https://github.com/certbot/certbot) (recommended but optional) |
@@ -13,2 +13,3 @@ ({ | ||
watch: 'number', | ||
test: 'number', | ||
}, | ||
@@ -15,0 +16,0 @@ queue: { |
@@ -30,2 +30,3 @@ export interface LogConfig { | ||
watch: number; | ||
test: number; | ||
}; | ||
@@ -32,0 +33,0 @@ queue: { |
68141
33
1790
7
Updatedmetacom@^3.1.1
Updatedmetautil@^3.14.0
Updatedmetavm@^1.3.0