Skip to content

Commit c4176e8

Browse files
committed
test: skip tests not passing without NODE_OPTIONS support
1 parent 5879e9b commit c4176e8

14 files changed

+65
-22
lines changed

.github/workflows/test-shared.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192
--arg ccache '(import <nixpkgs> {}).sccache' \
193193
--arg devTools '[]' \
194194
--arg benchmarkTools '[]' \
195-
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-amaro" "--without-inspector"]'' \' || '\' }}
195+
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-amaro" "--without-inspector" "--without-node-options"]'' \' || '\' }}
196196
--run '
197197
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
198198
'

test/embedding/test-embedding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ for (const extraSnapshotArgs of [
154154
}
155155

156156
// Guarantee NODE_REPL_EXTERNAL_MODULE won't bypass kDisableNodeOptionsEnv
157-
{
157+
if (!process.config.variables.node_without_node_options) {
158158
spawnSyncAndExit(
159159
binary,
160160
['require("os")'],

test/es-module/test-esm-import-flag.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const cjsImport = fixtures.fileURL('es-modules', 'cjs-file.cjs');
99
const mjsEntry = fixtures.path('es-modules', 'mjs-file.mjs');
1010
const mjsImport = fixtures.fileURL('es-modules', 'mjs-file.mjs');
1111

12+
const onlyIfNodeOptionsSupport = { skip: process.config.variables.node_without_node_options };
1213

1314
describe('import modules using --import', { concurrency: !process.env.TEST_PARALLEL }, () => {
1415
it('should import when using --eval', async () => {
@@ -199,7 +200,7 @@ describe('import modules using --import', { concurrency: !process.env.TEST_PARAL
199200
assert.strictEqual(signal, null);
200201
});
201202

202-
it('should import files from the env before ones from the CLI', async () => {
203+
it('should import files from the env before ones from the CLI', onlyIfNodeOptionsSupport, async () => {
203204
const { code, signal, stderr, stdout } = await spawnPromisified(
204205
execPath,
205206
[

test/es-module/test-esm-symlink-type.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const assert = require('assert');
66
const exec = require('child_process').execFile;
77
const fs = require('fs');
88

9+
if (process.config.variables.node_without_node_options) {
10+
common.skip('missing NODE_OPTIONS support');
11+
}
12+
913
const tmpdir = require('../common/tmpdir');
1014
tmpdir.refresh();
1115
const tmpDir = tmpdir.path;

test/es-module/test-esm-type-field-errors.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const assert = require('assert');
44
const exec = require('child_process').execFile;
55
const { describe, it } = require('node:test');
66

7+
if (process.config.variables.node_without_node_options) {
8+
common.skip('missing NODE_OPTIONS support');
9+
}
10+
711
const mjsFile = require.resolve('../fixtures/es-modules/mjs-file.mjs');
812
const cjsFile = require.resolve('../fixtures/es-modules/cjs-file.cjs');
913
const packageWithoutTypeMain =

test/parallel/test-cli-options-as-flags.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const fixtureFile = fixtures.path(path.join('options-as-flags', 'fixture.cjs'));
1212
const configFile = fixtures.path(path.join('options-as-flags', 'test-config.json'));
1313
const envFile = fixtures.path(path.join('options-as-flags', '.test.env'));
1414

15+
const onlyIfNodeOptionsSupport = { skip: process.config.variables.node_without_node_options };
16+
1517
describe('getOptionsAsFlagsFromBinding', () => {
1618
it('should extract flags from command line arguments', async () => {
1719
const result = await spawnPromisified(process.execPath, [
@@ -28,7 +30,7 @@ describe('getOptionsAsFlagsFromBinding', () => {
2830
assert.strictEqual(flags.includes('--stack-trace-limit=512'), true);
2931
});
3032

31-
it('should extract flags from NODE_OPTIONS environment variable', async () => {
33+
it('should extract flags from NODE_OPTIONS environment variable', onlyIfNodeOptionsSupport, async () => {
3234
const result = await spawnPromisified(process.execPath, [
3335
'--no-warnings',
3436
'--expose-internals',
@@ -49,7 +51,7 @@ describe('getOptionsAsFlagsFromBinding', () => {
4951
assert.strictEqual(flags.includes('--no-warnings'), true);
5052
});
5153

52-
it('should extract flags from config file', async () => {
54+
it('should extract flags from config file', onlyIfNodeOptionsSupport, async () => {
5355
const result = await spawnPromisified(process.execPath, [
5456
'--no-warnings',
5557
'--expose-internals',
@@ -69,7 +71,7 @@ describe('getOptionsAsFlagsFromBinding', () => {
6971
assert.strictEqual(flags.includes('--no-warnings'), true);
7072
});
7173

72-
it('should extract flags from config file and command line', async () => {
74+
it('should extract flags from config file and command line', onlyIfNodeOptionsSupport, async () => {
7375
const result = await spawnPromisified(process.execPath, [
7476
'--no-warnings',
7577
'--expose-internals',
@@ -92,7 +94,7 @@ describe('getOptionsAsFlagsFromBinding', () => {
9294
assert.strictEqual(flags.includes('--test-isolation=none'), true);
9395
});
9496

95-
it('should extract flags from .env file', async () => {
97+
it('should extract flags from .env file', onlyIfNodeOptionsSupport, async () => {
9698
const result = await spawnPromisified(process.execPath, [
9799
'--no-warnings',
98100
'--expose-internals',

test/parallel/test-config-file.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ const { test, it, describe } = require('node:test');
1313
const { chmodSync, writeFileSync, constants } = require('node:fs');
1414
const { join } = require('node:path');
1515

16+
const onlyIfNodeOptionsSupport = { skip: process.config.variables.node_without_node_options };
1617
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
18+
const onlyWithAmaroAndNodeOptions = {
19+
skip: !process.config.variables.node_use_amaro || process.config.variables.node_without_node_options,
20+
};
21+
const onlyWithInspectorAndNodeOptions = {
22+
skip: !process.features.inspector || process.config.variables.node_without_node_options,
23+
};
1724

1825
test('should handle non existing json', async () => {
1926
const result = await spawnPromisified(process.execPath, [
@@ -51,7 +58,7 @@ test('should handle empty object json', async () => {
5158
assert.strictEqual(result.code, 0);
5259
});
5360

54-
test('should parse boolean flag', onlyWithAmaro, async () => {
61+
test('should parse boolean flag', onlyWithAmaroAndNodeOptions, async () => {
5562
const result = await spawnPromisified(process.execPath, [
5663
'--experimental-config-file',
5764
fixtures.path('rc/transform-types.json'),
@@ -62,7 +69,7 @@ test('should parse boolean flag', onlyWithAmaro, async () => {
6269
assert.strictEqual(result.code, 0);
6370
});
6471

65-
test('should parse boolean flag defaulted to true', async () => {
72+
test('should parse boolean flag defaulted to true', onlyIfNodeOptionsSupport, async () => {
6673
const result = await spawnPromisified(process.execPath, [
6774
'--experimental-config-file',
6875
fixtures.path('rc/warnings-false.json'),
@@ -85,7 +92,7 @@ test('should throw an error when a flag is declared twice', async () => {
8592
assert.strictEqual(result.code, 9);
8693
});
8794

88-
test('should override env-file', onlyWithAmaro, async () => {
95+
test('should override env-file', onlyWithAmaroAndNodeOptions, async () => {
8996
const result = await spawnPromisified(process.execPath, [
9097
'--no-warnings',
9198
'--experimental-config-file',
@@ -128,7 +135,7 @@ test('should not override CLI flags', onlyWithAmaro, async () => {
128135
assert.strictEqual(result.code, 1);
129136
});
130137

131-
test('should parse array flag correctly', async () => {
138+
test('should parse array flag correctly', onlyIfNodeOptionsSupport, async () => {
132139
const result = await spawnPromisified(process.execPath, [
133140
'--no-warnings',
134141
'--experimental-config-file',
@@ -152,7 +159,7 @@ test('should validate invalid array flag', async () => {
152159
assert.strictEqual(result.code, 9);
153160
});
154161

155-
test('should validate array flag as string', async () => {
162+
test('should validate array flag as string', onlyIfNodeOptionsSupport, async () => {
156163
const result = await spawnPromisified(process.execPath, [
157164
'--no-warnings',
158165
'--experimental-config-file',
@@ -188,7 +195,7 @@ test('should throw at flag not available in NODE_OPTIONS', async () => {
188195
assert.strictEqual(result.code, 9);
189196
});
190197

191-
test('unsigned flag should be parsed correctly', async () => {
198+
test('unsigned flag should be parsed correctly', onlyIfNodeOptionsSupport, async () => {
192199
const result = await spawnPromisified(process.execPath, [
193200
'--no-warnings',
194201
'--experimental-config-file',
@@ -225,7 +232,7 @@ test('v8 flag should not be allowed in config file', async () => {
225232
assert.strictEqual(result.code, 9);
226233
});
227234

228-
test('string flag should be parsed correctly', async () => {
235+
test('string flag should be parsed correctly', onlyIfNodeOptionsSupport, async () => {
229236
const result = await spawnPromisified(process.execPath, [
230237
'--no-warnings',
231238
'--test',
@@ -238,7 +245,7 @@ test('string flag should be parsed correctly', async () => {
238245
assert.strictEqual(result.code, 0);
239246
});
240247

241-
test('host port flag should be parsed correctly', { skip: !process.features.inspector }, async () => {
248+
test('host port flag should be parsed correctly', onlyWithInspectorAndNodeOptions, async () => {
242249
const result = await spawnPromisified(process.execPath, [
243250
'--no-warnings',
244251
'--expose-internals',
@@ -251,7 +258,7 @@ test('host port flag should be parsed correctly', { skip: !process.features.insp
251258
assert.strictEqual(result.code, 0);
252259
});
253260

254-
test('--inspect=true should be parsed correctly', { skip: !process.features.inspector }, async () => {
261+
test('--inspect=true should be parsed correctly', onlyWithInspectorAndNodeOptions, async () => {
255262
const result = await spawnPromisified(process.execPath, [
256263
'--no-warnings',
257264
'--experimental-config-file',
@@ -351,7 +358,7 @@ test('broken value in node_options', async () => {
351358
assert.strictEqual(result.code, 9);
352359
});
353360

354-
test('should use node.config.json as default', async () => {
361+
test('should use node.config.json as default', onlyIfNodeOptionsSupport, async () => {
355362
const result = await spawnPromisified(process.execPath, [
356363
'--no-warnings',
357364
'--experimental-default-config-file',
@@ -364,7 +371,7 @@ test('should use node.config.json as default', async () => {
364371
assert.strictEqual(result.code, 0);
365372
});
366373

367-
test('should override node.config.json when specificied', async () => {
374+
test('should override node.config.json when specificied', onlyIfNodeOptionsSupport, async () => {
368375
const result = await spawnPromisified(process.execPath, [
369376
'--no-warnings',
370377
'--experimental-default-config-file',

test/parallel/test-max-old-space-size-percentage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ invalidPercentages.forEach((input) => {
4444
assert.match(result.stderr.toString(), input[1]);
4545
});
4646

47+
if (process.config.variables.node_without_node_options) {
48+
common.skip('missing NODE_OPTIONS support');
49+
}
50+
4751
// Test NODE_OPTIONS with valid percentages
4852
validPercentages.forEach((input) => {
4953
const result = spawnSync(process.execPath, [], {

test/parallel/test-permission-allow-child-process-cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const { isMainThread } = require('worker_threads');
88
if (!isMainThread) {
99
common.skip('This test only works on a main thread');
1010
}
11+
if (process.config.variables.node_without_node_options) {
12+
common.skip('missing NODE_OPTIONS support');
13+
}
1114

1215
const assert = require('assert');
1316
const childProcess = require('child_process');

test/parallel/test-permission-child-process-inherit-flags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const { isMainThread } = require('worker_threads');
77
if (!isMainThread) {
88
common.skip('This test only works on a main thread');
99
}
10+
if (process.config.variables.node_without_node_options) {
11+
common.skip('missing NODE_OPTIONS support');
12+
}
1013

1114
const assert = require('assert');
1215
const childProcess = require('child_process');

0 commit comments

Comments
 (0)