Skip to content

Commit

Permalink
test: remove experimental-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-frankqiu committed Oct 24, 2021
1 parent 2324f1f commit 1ba1c12
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/parallel/test-process-env-allowed-flags-are-documented.js
Expand Up @@ -15,7 +15,9 @@ const parseSection = (text, startMarker, endMarker) => {
const match = text.match(regExp);
assert(match,
`Unable to locate text between '${startMarker}' and '${endMarker}'.`);
return match[1].split(/\r?\n/);
return match[1]
.split(/\r?\n/)
.filter((val) => val.trim() !== '');
};

const nodeOptionsLines = parseSection(cliText,
Expand All @@ -24,28 +26,35 @@ const nodeOptionsLines = parseSection(cliText,
const v8OptionsLines = parseSection(cliText,
'<!-- node-options-v8 start -->',
'<!-- node-options-v8 end -->');

// Check the options are documented in alphabetical order.
assert.deepStrictEqual(nodeOptionsLines, [...nodeOptionsLines].sort());
assert.deepStrictEqual(v8OptionsLines, [...v8OptionsLines].sort());

const documented = new Set();
for (const line of [...nodeOptionsLines, ...v8OptionsLines]) {
for (const match of line.matchAll(/`(-[^`]+)`/g)) {
const option = match[1];
// Remove negation from the option's name.
const option = match[1].replace('--no-', '--');
assert(!documented.has(option),
`Option '${option}' was documented more than once as an ` +
`allowed option for NODE_OPTIONS in ${cliMd}.`);
documented.add(option);
}
}

if (!common.hasOpenSSL3) {
documented.delete('--openssl-legacy-provider');
}

// Filter out options that are conditionally present.
const conditionalOpts = [
{
include: common.hasCrypto,
filter: (opt) => {
return [
'--openssl-config',
common.hasOpenSSL3 ? '--openssl-legacy-provider' : '',
'--tls-cipher-list',
'--use-bundled-ca',
'--use-openssl-ca',
Expand Down Expand Up @@ -86,12 +95,25 @@ const undocumented = difference(process.allowedNodeEnvironmentFlags,
documented);
// Remove intentionally undocumented options.
assert(undocumented.delete('--debug-arraybuffer-allocations'));
assert(undocumented.delete('--no-debug-arraybuffer-allocations'));
assert(undocumented.delete('--es-module-specifier-resolution'));
assert(undocumented.delete('--experimental-report'));
assert(undocumented.delete('--experimental-worker'));
assert(undocumented.delete('--node-snapshot'));
assert(undocumented.delete('--no-node-snapshot'));
assert(undocumented.delete('--loader'));
assert(undocumented.delete('--verify-base-objects'));
assert(undocumented.delete('--no-verify-base-objects'));
assert(undocumented.delete('--experimental-modules'));


// Remove negated versions of the flags.
for (const flag of undocumented) {
if (flag.startsWith('--no-')) {
assert(documented.has(`--${flag.slice(5)}`), flag);
undocumented.delete(flag);
}
}

assert.strictEqual(undocumented.size, 0,
'The following options are not documented as allowed in ' +
Expand Down

0 comments on commit 1ba1c12

Please sign in to comment.