-
Notifications
You must be signed in to change notification settings - Fork 29.7k
/
test-process-versions.js
105 lines (86 loc) Β· 2.97 KB
/
test-process-versions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'use strict';
const common = require('../common');
const assert = require('assert');
// Import of pure js (non-shared) deps for comparison
const acorn = require('../../deps/acorn/acorn/package.json');
const cjs_module_lexer = require('../../deps/cjs-module-lexer/package.json');
const expected_keys = [
'ares',
'brotli',
'modules',
'uv',
'v8',
'zlib',
'nghttp2',
'napi',
'llhttp',
'uvwasi',
'acorn',
'simdutf',
'ada',
'cjs_module_lexer',
'base64',
];
const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
if (hasUndici) {
expected_keys.push('undici');
}
if (common.hasCrypto) {
expected_keys.push('openssl');
}
if (common.hasQuic) {
expected_keys.push('ngtcp2');
expected_keys.push('nghttp3');
}
if (common.hasIntl) {
expected_keys.push('icu');
expected_keys.push('cldr');
expected_keys.push('tz');
expected_keys.push('unicode');
}
expected_keys.sort();
expected_keys.unshift('node');
const actual_keys = Object.keys(process.versions);
assert.deepStrictEqual(actual_keys, expected_keys);
const commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/;
assert.match(process.versions.acorn, commonTemplate);
assert.match(process.versions.ares, commonTemplate);
assert.match(process.versions.brotli, commonTemplate);
assert.match(process.versions.llhttp, commonTemplate);
assert.match(process.versions.node, commonTemplate);
assert.match(process.versions.uv, commonTemplate);
assert.match(process.versions.zlib, commonTemplate);
if (hasUndici) {
assert.match(process.versions.undici, commonTemplate);
}
assert.match(
process.versions.v8,
/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
);
assert.match(process.versions.modules, /^\d+$/);
assert.match(process.versions.cjs_module_lexer, commonTemplate);
if (common.hasCrypto) {
const versionRegex = common.hasOpenSSL3 ?
// The following also matches a development version of OpenSSL 3.x which
// can be in the format '3.0.0-alpha4-dev'. This can be handy when building
// and linking against the main development branch of OpenSSL.
/^\d+\.\d+\.\d+(?:[-+][a-z0-9]+)*$/ :
/^\d+\.\d+\.\d+[a-z]?(\+quic)?(-fips)?$/;
assert.match(process.versions.openssl, versionRegex);
}
for (let i = 0; i < expected_keys.length; i++) {
const key = expected_keys[i];
const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);
assert.strictEqual(descriptor.writable, false);
}
assert.strictEqual(process.config.variables.napi_build_version,
process.versions.napi);
if (hasUndici) {
const undici = require('../../deps/undici/src/package.json');
const expectedUndiciVersion = undici.version;
assert.strictEqual(process.versions.undici, expectedUndiciVersion);
}
const expectedAcornVersion = acorn.version;
assert.strictEqual(process.versions.acorn, expectedAcornVersion);
const expectedCjsModuleLexerVersion = cjs_module_lexer.version;
assert.strictEqual(process.versions.cjs_module_lexer, expectedCjsModuleLexerVersion);