Skip to content

Commit 5e30dbf

Browse files
committed
src: make the default value of strip_types AMARO
the default value of strip_types is controlled by node_options.h and we need to change the default value there Fixes: #60815
1 parent 48a8c31 commit 5e30dbf

11 files changed

+38
-22
lines changed

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class EnvironmentOptions : public Options {
259259

260260
std::vector<std::string> preload_esm_modules;
261261

262-
bool strip_types = true;
262+
bool strip_types = HAVE_AMARO;
263263
bool experimental_transform_types = false;
264264

265265
std::vector<std::string> user_argv;

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { spawn } from 'node:child_process';
44
import { describe, it } from 'node:test';
55
import assert from 'node:assert';
66

7+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
8+
79
describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => {
810
describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => {
911
it('permits ESM syntax in --eval input without requiring --input-type=module', async () => {
@@ -264,7 +266,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
264266
});
265267

266268
it('still throws on `await` in an ordinary sync function',
267-
{ skip: !process.config.variables.node_use_amaro },
269+
onlyWithAmaro,
268270
async () => {
269271
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
270272
'--eval',
@@ -317,7 +319,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
317319
});
318320

319321
it('still throws on double `const` declaration not at the top level',
320-
{ skip: !process.config.variables.node_use_amaro },
322+
onlyWithAmaro,
321323
async () => {
322324
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
323325
'--eval',

test/es-module/test-esm-import-meta-main-eval.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function wrapScriptInUrlWorker(script) {
2121
`;
2222
}
2323

24+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
25+
2426
describe('import.meta.main in evaluated scripts', () => {
2527
const importMetaMainScript = `
2628
import assert from 'node:assert/strict';
@@ -85,7 +87,7 @@ const { isMain: importedModuleIsMain } = await import(
8587
assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module');
8688
`;
8789

88-
it('should evaluate true in evaluated script', { skip: !process.config.variables.node_use_amaro }, async () => {
90+
it('should evaluate true in evaluated script', onlyWithAmaro, async () => {
8991
const result = await spawnPromisified(
9092
process.execPath,
9193
['--input-type=module-typescript', '--disable-warning=ExperimentalWarning', '--eval', importMetaMainTSScript],
@@ -99,7 +101,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
99101
});
100102

101103
it('should evaluate true in worker instantiated with module source by evaluated script',
102-
{ skip: !process.config.variables.node_use_amaro },
104+
onlyWithAmaro,
103105
async () => {
104106
const result = await spawnPromisified(
105107
process.execPath,
@@ -117,7 +119,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
117119
});
118120

119121
it('should evaluate true in worker instantiated with `data:` URL by evaluated script',
120-
{ skip: !process.config.variables.node_use_amaro },
122+
onlyWithAmaro,
121123
async () => {
122124
const result = await spawnPromisified(
123125
process.execPath,

test/es-module/test-esm-loader-entry-url.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ async function assertSpawnedProcess(args, options = {}, expected = {}) {
2323
// Common expectation for experimental feature warning in stderr
2424
const experimentalFeatureWarning = { stderr: /--entry-url is an experimental feature/ };
2525

26+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
27+
2628
describe('--entry-url', { concurrency: true }, () => {
2729
it('should reject loading a path that contains %', async () => {
2830
await assertSpawnedProcess(
@@ -76,7 +78,7 @@ describe('--entry-url', { concurrency: true }, () => {
7678
);
7779
});
7880

79-
it('should support loading TypeScript URLs', { skip: !process.config.variables.node_use_amaro }, async () => {
81+
it('should support loading TypeScript URLs', onlyWithAmaro, async () => {
8082
const typescriptUrls = [
8183
'typescript/cts/test-require-ts-file.cts',
8284
'typescript/mts/test-import-ts-file.mts',

test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { spawnPromisified } from '../common/index.mjs';
22
import { describe, it } from 'node:test';
33
import assert from 'node:assert';
44

5+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
6+
57
describe('unusual top-level await syntax errors', () => {
68
const expressions = [
79
// string
@@ -50,7 +52,7 @@ describe('unusual top-level await syntax errors', () => {
5052
});
5153

5254
it('should throw the error for unrelated syntax errors',
53-
{ skip: !process.config.variables.node_use_amaro },
55+
onlyWithAmaro,
5456
async () => {
5557
const expression = 'foo bar';
5658
const wrapperExpressions = [

test/parallel/test-cli-node-options-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
6464
}
6565

6666
// Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available)
67-
if (config.includes('HAVE_AMARO')) {
67+
if (process.config.variables.node_use_amaro) {
6868
hasTrueAsDefaultValue = true;
6969
}
7070

test/parallel/test-config-file.js

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

16+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
17+
1618
test('should handle non existing json', async () => {
1719
const result = await spawnPromisified(process.execPath, [
1820
'--experimental-config-file',
@@ -49,7 +51,7 @@ test('should handle empty object json', async () => {
4951
assert.strictEqual(result.code, 0);
5052
});
5153

52-
test('should parse boolean flag', { skip: !process.config.variables.node_use_amaro }, async () => {
54+
test('should parse boolean flag', onlyWithAmaro, async () => {
5355
const result = await spawnPromisified(process.execPath, [
5456
'--experimental-config-file',
5557
fixtures.path('rc/transform-types.json'),
@@ -84,7 +86,7 @@ test('should throw an error when a flag is declared twice', async () => {
8486
});
8587

8688

87-
test('should override env-file', { skip: !process.config.variables.node_use_amaro }, async () => {
89+
test('should override env-file', onlyWithAmaro, async () => {
8890
const result = await spawnPromisified(process.execPath, [
8991
'--no-warnings',
9092
'--experimental-config-file',
@@ -97,7 +99,7 @@ test('should override env-file', { skip: !process.config.variables.node_use_amar
9799
assert.strictEqual(result.code, 0);
98100
});
99101

100-
test('should not override NODE_OPTIONS', { skip: !process.config.variables.node_use_amaro }, async () => {
102+
test('should not override NODE_OPTIONS', onlyWithAmaro, async () => {
101103
const result = await spawnPromisified(process.execPath, [
102104
'--no-warnings',
103105
'--experimental-config-file',
@@ -114,7 +116,7 @@ test('should not override NODE_OPTIONS', { skip: !process.config.variables.node_
114116
assert.strictEqual(result.code, 1);
115117
});
116118

117-
test('should not override CLI flags', { skip: !process.config.variables.node_use_amaro }, async () => {
119+
test('should not override CLI flags', onlyWithAmaro, async () => {
118120
const result = await spawnPromisified(process.execPath, [
119121
'--no-warnings',
120122
'--no-experimental-transform-types',

test/parallel/test-runner-coverage-default-exclusion.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ async function setupFixtures() {
1616
await cp(fixtureDir, tmpdir.path, { recursive: true });
1717
}
1818

19+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
20+
1921
describe('test runner coverage default exclusion', skipIfNoInspector, () => {
2022
before(async () => {
2123
await setupFixtures();
@@ -86,7 +88,7 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => {
8688
assert.strictEqual(result.status, 0);
8789
});
8890

89-
it('should exclude ts test files', { skip: !process.config.variables.node_use_amaro }, async () => {
91+
it('should exclude ts test files', onlyWithAmaro, async () => {
9092
const report = [
9193
'# start of coverage report',
9294
'# --------------------------------------------------------------',

test/parallel/test-runner-global-setup-teardown.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { join } from 'node:path';
1010

1111
const testFixtures = fixtures.path('test-runner');
1212

13+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
14+
1315
async function runTest(
1416
{
1517
isolation,
@@ -257,7 +259,7 @@ async function runTest(
257259
});
258260

259261
it('should run TypeScript globalSetup and globalTeardown functions',
260-
{ skip: !process.config.variables.node_use_amaro },
262+
onlyWithAmaro,
261263
async () => {
262264
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
263265
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');

test/parallel/test-runner-run-global-hooks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false },
167167
});
168168

169169
it('should run TypeScript globalSetup and globalTeardown functions',
170-
{ skip: !process.config.variables.node_use_amaro },
170+
onlyWithAmaro,
171171
async () => {
172172
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
173173
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');

0 commit comments

Comments
 (0)