Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-all-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ["18", "20", "22"]
node: ["18", "20", "22", "24"]
runs-on: ubuntu-latest
services:
mongo:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
- "20.6.0"
- "20"
- "22"
- "24"
include:
- node: 18
code-coverage: true
Expand Down
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/instrumentation-knex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@opentelemetry/sdk-trace-node": "^2.0.0",
"@types/mocha": "10.0.10",
"@types/node": "18.18.14",
"better-sqlite3": "11.0.0",
"better-sqlite3": "^11.10.0",
"knex": "3.1.0",
"nyc": "17.1.0",
"rimraf": "5.0.10",
Expand Down
6 changes: 5 additions & 1 deletion packages/instrumentation-restify/.tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ restify:
- versions:
include: '>=10.0.0 <12'
mode: latest-minors
node: ">=18"
node: ">=18 <24"
commands: npm run test
env:
- SKIP_TEST_IF_DISABLED=true

- versions:
include: '>=4.1.0 <10'
mode: max-7
node: "<18"
commands: npm run test
env:
- SKIP_TEST_IF_DISABLED=true
2 changes: 1 addition & 1 deletion packages/instrumentation-restify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint:readme": "node ../../scripts/lint-readme.js",
"prepublishOnly": "npm run compile",
"tdd": "yarn test -- --watch-extensions ts --watch",
"test": "nyc mocha 'test/**/*.ts'",
"test": "SKIP_TEST_IF_NODE_NEWER_THAN=23 nyc mocha --require '../../scripts/skip-test-if.js' 'test/**/*.ts'",
"test-all-versions": "tav",
"version:update": "node ../../scripts/version-update.js",
"watch": "tsc -w"
Expand Down
9 changes: 8 additions & 1 deletion packages/instrumentation-tedious/.tav.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
tedious:
- versions:
include: ">=1.11.0 <12"
include: ">=1.11.0 <2"
mode: latest-majors
# tedious@1 uses tls.createSecurePair() which was removed in Node.js 24
# (https://nodejs.org/api/all.html#DEP0064).
node: "<24"
commands: npm run test
- versions:
include: ">=2 <12"
# 4.0.0 is broken: https://github.com/tediousjs/tedious/commit/4eceb48
exclude: "4.0.0"
mode: latest-majors
Expand Down
50 changes: 36 additions & 14 deletions scripts/skip-test-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,62 @@

/**
* This script can be used with `mocha --require ...` to support skipping
* tests if the current version of Node.js is too old. For example, say
* a package's unit tests cannot run with Node.js 14, but the CI unit tests
* run all package test with that version.
* tests if the current version of Node.js is too old or too new. For example,
* say a package's unit tests cannot run with Node.js 14, but the CI unit tests
* run all package tests with that version.
*
* 1. Change this in "package.json":
* "test": "nyc mocha ...",
* to this:
* "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../../scripts/skip-test-if.js' ... ",
* where `SKIP_TEST_IF_NODE_OLDER_THAN` indicates the minimum Node.js major
* version.
* to one of these:
* "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../scripts/skip-test-if.js' ...",
* "test": "SKIP_TEST_IF_NODE_NEWER_THAN=22 nyc mocha --require '../../scripts/skip-test-if.js' ...",
* where `SKIP_TEST_IF_NODE_{OLDER|NEWER}_THAN` indicates a Node.js *major*
* version number.
*
* 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLE=true to
* 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLED=true to
* disable the skipping. Via this in each test block:
* env:
* - SKIP_TEST_IF_DISABLE=true
* - SKIP_TEST_IF_DISABLED=true
*/

function skipTestIf() {
if (process.env.SKIP_TEST_IF_DISABLE) {
if (process.env.SKIP_TEST_IF_DISABLED) {
return;
}

const minNodeMajor = process.env.SKIP_TEST_IF_NODE_OLDER_THAN ?? Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN);
if (!minNodeMajor || isNaN(minNodeMajor)) {
console.warn('skip-test-if warning: set a minimum Node.js major version via SKIP_TEST_IF_NODE_OLDER_THAN=<num>');
let minNodeMajor;
if (process.env.SKIP_TEST_IF_NODE_OLDER_THAN) {
minNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN)
if (isNaN(minNodeMajor) || !Number.isInteger(minNodeMajor)) {
console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_OLDER_THAN value: "${process.env.SKIP_TEST_IF_NODE_OLDER_THAN}"`);
minNodeMajor = undefined;
}
}
let maxNodeMajor;
if (process.env.SKIP_TEST_IF_NODE_NEWER_THAN) {
maxNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_NEWER_THAN)
if (isNaN(maxNodeMajor) || !Number.isInteger(maxNodeMajor)) {
console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_NEWER_THAN value: "${process.env.SKIP_TEST_IF_NODE_NEWER_THAN}"`);
maxNodeMajor = undefined;
}
}

if (minNodeMajor === undefined && maxNodeMajor === undefined) {
console.warn('skip-test-if warning: skip-test-if.js was used, but no SKIP_TEST_IF_* envvars were set');
return;
}

const nodeMajor = Number(process.versions.node.split('.')[0]);
if (nodeMajor < minNodeMajor) {
if (minNodeMajor && nodeMajor < minNodeMajor) {
process.stderr.write(`skip-test-if: skipping tests on old Node.js (${nodeMajor} < ${minNodeMajor})\n`);
// "Skip" tests by exiting the process. Mocha is all in one process.
process.exit(0);
}
if (maxNodeMajor && nodeMajor > maxNodeMajor) {
process.stderr.write(`skip-test-if: skipping tests on too-new Node.js (${nodeMajor} > ${maxNodeMajor})\n`);
// "Skip" tests by exiting the process. Mocha is all in one process.
process.exit(0);
}
}

skipTestIf()
Expand Down
Loading