openvibers/openvibe.publishing Commits
npm test no longer counts a skipped test as passed (roadmap WS-Q task 7; openvibe-shared/test-runner, Shared v1.25.0). test/run.js counted every file that exited 0 as passed, so a file that printed that it skipped its work and checked nothing still read as green. It is now the shared runner (same files, a few at a time as before, 60 s timeout per file): a test prints "<label>: skipped (<why>)" for what it could not run, and that file is listed with ○ and its reasons and not counted as passed; --strict makes a skip fail the run. No test here skips anything. The openvibe-shared dev dependency the tests use is pinned at v1.25.0 (from v1.22.0; the peer range stays >=1.5.0; the README follows). npm test (Node 22) 13/13.
Changes
@@@ -205,7 +205,7 @@ fnm exec --using=22.22.1 npm test # every test/*.test.js, temp database## Depends on--- `openvibe-shared` ≥ 1.5.0 (`seo`), a peer dependency supplied by the consumer (tests use v1.22.0).++- `openvibe-shared` ≥ 1.5.0 (`seo`), a peer dependency supplied by the consumer (tests use v1.25.0).- `better-sqlite3` ≥ 11, supplied by the consumer.- Contracts it produces for: `common.entity-ref@1`, `media.media-ref@1`, `events.event-envelope@1`and `search.index-document@1` (validated in tests against `openvibe-contracts` v0.49.0, a@@@ -13,7 +13,7 @@"ajv-formats": "^3.0.1","better-sqlite3": "^11.10.0","openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",-- "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0"++ "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0"},"engines": {"node": ">=20"@@@ -490,9 +490,9 @@}},"node_modules/openvibe-shared": {-- "version": "1.22.0",-- "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0",-- "integrity": "sha512-FtqbR8h6YphOnJNqklJED3HyqvTwZJl58gyiZ3QgzmZtZcA16O2NMGq67O4p7grLojwaIG5DhXDMgmZcpScxJQ==",++ "version": "1.25.0",++ "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0",++ "integrity": "sha512-oqZ+PvljrWi8IEbtg6bDYai17ZV2sALFx/ezMptniELSr10TgFUiGUQt+b1IWwiHv0T2Y1U2iSrkirJxMNgjSw==","dev": true,"license": "MIT","dependencies": {@@@ -49,6 +49,6 @@"ajv-formats": "^3.0.1","better-sqlite3": "^11.10.0","openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",-- "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0"++ "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0"}}@@@ -5,58 +5,12 @@** npm test # everything* npm test -- seo revisions # only files whose name contains one of the words++ * npm test -- --strict # a skipped test fails the run too** Plain Node: temp SQLite files, in-process HTTP, no network.++ *++ * A test that cannot run something here prints `<label>: skipped (<why>)`: that file is listed with++ * ○ and not counted as passed (openvibe-shared/test-runner).*/'use strict';--const { spawn } = require('child_process');--const fs = require('fs');--const os = require('os');--const path = require('path');----const filters = process.argv.slice(2).filter((a) => !a.startsWith('-'));--const files = fs.readdirSync(__dirname)-- .filter((f) => f.endsWith('.test.js'))-- .filter((f) => !filters.length || filters.some((w) => f.includes(w)))-- .sort();--const PARALLEL = Math.max(1, Math.min(4, os.cpus().length - 1));--const TIMEOUT_MS = 60000;----function runOne(file) {-- return new Promise((resolve) => {-- const started = Date.now();-- const child = spawn(process.execPath, [path.join(__dirname, file)], {-- cwd: path.join(__dirname, '..'),-- env: { ...process.env, NODE_ENV: 'test' },-- stdio: ['ignore', 'pipe', 'pipe'],-- });-- let output = '';-- child.stdout.on('data', (c) => { output += c; });-- child.stderr.on('data', (c) => { output += c; });-- const timer = setTimeout(() => { output += `\n[run] timed out after ${TIMEOUT_MS}ms`; child.kill('SIGKILL'); }, TIMEOUT_MS);-- child.on('close', (code, signal) => {-- clearTimeout(timer);-- resolve({ file, ok: code === 0, code: code ?? signal, ms: Date.now() - started, output });-- });-- });--}----(async () => {-- if (!files.length) { console.error('no test files matched'); process.exit(1); }-- const queue = [...files];-- const results = [];-- await Promise.all(Array.from({ length: PARALLEL }, async () => {-- while (queue.length) {-- const r = await runOne(queue.shift());-- results.push(r);-- console.log(`${r.ok ? '✓' : '✗'} ${r.file.padEnd(32)} ${String(r.ms).padStart(6)}ms`);-- }-- }));-- const failed = results.filter((r) => !r.ok);-- for (const r of failed) {-- console.log(`\n── ${r.file} (exit ${r.code}) ──`);-- console.log(r.output.split('\n').slice(-40).join('\n'));-- }-- console.log(`\n${results.length - failed.length}/${results.length} test files passed`);-- process.exit(failed.length ? 1 : 0);--})();++require('openvibe-shared/test-runner').main({ dir: __dirname, timeoutMs: 60000, pad: 32 });
@@ -205,7 +205,7 @@ fnm exec --using=22.22.1 npm test # every test/*.test.js, temp database
@@ -205,7 +205,7 @@ fnm exec --using=22.22.1 npm test # every test/*.test.js, temp database
## Depends on
## Depends on
-- `openvibe-shared` ≥ 1.5.0 (`seo`), a peer dependency supplied by the consumer (tests use v1.22.0).
+- `openvibe-shared` ≥ 1.5.0 (`seo`), a peer dependency supplied by the consumer (tests use v1.25.0).
- `better-sqlite3` ≥ 11, supplied by the consumer.
- `better-sqlite3` ≥ 11, supplied by the consumer.
- Contracts it produces for: `common.entity-ref@1`, `media.media-ref@1`, `events.event-envelope@1`
- Contracts it produces for: `common.entity-ref@1`, `media.media-ref@1`, `events.event-envelope@1`
and `search.index-document@1` (validated in tests against `openvibe-contracts` v0.49.0, a
and `search.index-document@1` (validated in tests against `openvibe-contracts` v0.49.0, a
@@ -13,7 +13,7 @@
@@ -13,7 +13,7 @@
"ajv-formats": "^3.0.1",
"ajv-formats": "^3.0.1",
"better-sqlite3": "^11.10.0",
"better-sqlite3": "^11.10.0",
"openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",
"openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",
- "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0"
+ "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0"
},
},
"engines": {
"engines": {
"node": ">=20"
"node": ">=20"
@@ -490,9 +490,9 @@
@@ -490,9 +490,9 @@
}
}
},
},
"node_modules/openvibe-shared": {
"node_modules/openvibe-shared": {
- "version": "1.22.0",
- "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0",
- "integrity": "sha512-FtqbR8h6YphOnJNqklJED3HyqvTwZJl58gyiZ3QgzmZtZcA16O2NMGq67O4p7grLojwaIG5DhXDMgmZcpScxJQ==",
+ "version": "1.25.0",
+ "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0",
+ "integrity": "sha512-oqZ+PvljrWi8IEbtg6bDYai17ZV2sALFx/ezMptniELSr10TgFUiGUQt+b1IWwiHv0T2Y1U2iSrkirJxMNgjSw==",
"dev": true,
"dev": true,
"license": "MIT",
"license": "MIT",
"dependencies": {
"dependencies": {
@@ -49,6 +49,6 @@
@@ -49,6 +49,6 @@
"ajv-formats": "^3.0.1",
"ajv-formats": "^3.0.1",
"better-sqlite3": "^11.10.0",
"better-sqlite3": "^11.10.0",
"openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",
"openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.49.0",
- "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.22.0"
+ "openvibe-shared": "https://codeload.github.com/OpenVibers/OpenVibe.Shared/tar.gz/refs/tags/v1.25.0"
}
}
}
}
@@ -5,58 +5,12 @@
@@ -5,58 +5,12 @@
*
*
* npm test # everything
* npm test # everything
* npm test -- seo revisions # only files whose name contains one of the words
* npm test -- seo revisions # only files whose name contains one of the words
+ * npm test -- --strict # a skipped test fails the run too
*
*
* Plain Node: temp SQLite files, in-process HTTP, no network.
* Plain Node: temp SQLite files, in-process HTTP, no network.
+ *
+ * A test that cannot run something here prints `<label>: skipped (<why>)`: that file is listed with
+ * ○ and not counted as passed (openvibe-shared/test-runner).
*/
*/
'use strict';
'use strict';
-const { spawn } = require('child_process');
-const fs = require('fs');
-const os = require('os');
-const path = require('path');
-
-const filters = process.argv.slice(2).filter((a) => !a.startsWith('-'));
-const files = fs.readdirSync(__dirname)
- .filter((f) => f.endsWith('.test.js'))
- .filter((f) => !filters.length || filters.some((w) => f.includes(w)))
- .sort();
-const PARALLEL = Math.max(1, Math.min(4, os.cpus().length - 1));
-const TIMEOUT_MS = 60000;
-
-function runOne(file) {
- return new Promise((resolve) => {
- const started = Date.now();
- const child = spawn(process.execPath, [path.join(__dirname, file)], {
- cwd: path.join(__dirname, '..'),
- env: { ...process.env, NODE_ENV: 'test' },
- stdio: ['ignore', 'pipe', 'pipe'],
- });
- let output = '';
- child.stdout.on('data', (c) => { output += c; });
- child.stderr.on('data', (c) => { output += c; });
- const timer = setTimeout(() => { output += `\n[run] timed out after ${TIMEOUT_MS}ms`; child.kill('SIGKILL'); }, TIMEOUT_MS);
- child.on('close', (code, signal) => {
- clearTimeout(timer);
- resolve({ file, ok: code === 0, code: code ?? signal, ms: Date.now() - started, output });
- });
- });
-}
-
-(async () => {
- if (!files.length) { console.error('no test files matched'); process.exit(1); }
- const queue = [...files];
- const results = [];
- await Promise.all(Array.from({ length: PARALLEL }, async () => {
- while (queue.length) {
- const r = await runOne(queue.shift());
- results.push(r);
- console.log(`${r.ok ? '✓' : '✗'} ${r.file.padEnd(32)} ${String(r.ms).padStart(6)}ms`);
- }
- }));
- const failed = results.filter((r) => !r.ok);
- for (const r of failed) {
- console.log(`\n── ${r.file} (exit ${r.code}) ──`);
- console.log(r.output.split('\n').slice(-40).join('\n'));
- }
- console.log(`\n${results.length - failed.length}/${results.length} test files passed`);
- process.exit(failed.length ? 1 : 0);
-})();
+require('openvibe-shared/test-runner').main({ dir: __dirname, timeoutMs: 60000, pad: 32 });