Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

fix broken tests on node 12; latest pnpm requires node >= 14.19 #1613

Merged
merged 6 commits into from
May 5, 2022
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
8 changes: 1 addition & 7 deletions test/test-10-pnpm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');

// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
if (MAJOR_VERSION < 12) {
console.log(
'skiping test as it requires nodejs >= 12 and got',
MAJOR_VERSION
);
if (utils.shouldSkipPnpm()) {
return;
}

Expand Down
8 changes: 1 addition & 7 deletions test/test-11-pnpm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');

// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
if (MAJOR_VERSION < 12) {
console.log(
'skiping test as it requires nodejs >= 12 and got',
MAJOR_VERSION
);
if (utils.shouldSkipPnpm()) {
return;
}

Expand Down
4 changes: 1 addition & 3 deletions test/test-12-compression-node-opcua/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const utils = require('../utils.js');
assert(!module.parent);
assert(__dirname === process.cwd());

// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
if (MAJOR_VERSION < 12) {
if (utils.shouldSkipPnpm()) {
return;
}

Expand Down
19 changes: 19 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,22 @@ module.exports.filesAfter = function (b, n) {
module.exports.vacuum.sync(ni);
}
};

module.exports.shouldSkipPnpm = function () {
const REQUIRED_MAJOR_VERSION = 14;
const REQUIRED_MINOR_VERSION = 19;

const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
const MINOR_VERSION = parseInt(process.version.match(/v[0-9]+\.([0-9]+)/)[1], 10);

const isDisallowedMajor = MAJOR_VERSION < REQUIRED_MAJOR_VERSION
const isDisallowedMinor = MAJOR_VERSION === REQUIRED_MAJOR_VERSION && MINOR_VERSION < REQUIRED_MINOR_VERSION;
if (isDisallowedMajor || isDisallowedMinor) {
const need = `${REQUIRED_MAJOR_VERSION}.${REQUIRED_MINOR_VERSION}`;
const got = `${MAJOR_VERSION}.${MINOR_VERSION}`;
console.log(`skiping test as it requires nodejs >= ${need} and got ${got}`);
return true;
}

return false;
}