Skip to content

Commit d09c3ff

Browse files
authored
test: skip failing tests when compiled without amaro
When compiled without amaro, this conflicts with --experimental-strip-types defaulting to true. To avoid that, we need to skip relevant failing tests. Fixes: #60640 PR-URL: #60815 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 1b3a64d commit d09c3ff

19 files changed

+71
-27
lines changed

src/node_options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
10921092
"Type-stripping for TypeScript files.",
10931093
&EnvironmentOptions::strip_types,
10941094
kAllowedInEnvvar,
1095-
true);
1095+
HAVE_AMARO);
10961096
AddAlias("--experimental-strip-types", "--strip-types");
10971097
AddOption("--experimental-transform-types",
10981098
"enable transformation of TypeScript-only"

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-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', 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],
@@ -98,7 +100,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
98100
});
99101
});
100102

101-
it('should evaluate true in worker instantiated with module source by evaluated script', async () => {
103+
it('should evaluate true in worker instantiated with module source by evaluated script', onlyWithAmaro, async () => {
102104
const result = await spawnPromisified(
103105
process.execPath,
104106
['--input-type=module-typescript',
@@ -114,7 +116,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
114116
});
115117
});
116118

117-
it('should evaluate true in worker instantiated with `data:` URL by evaluated script', async () => {
119+
it('should evaluate true in worker instantiated with `data:` URL by evaluated script', onlyWithAmaro, async () => {
118120
const result = await spawnPromisified(
119121
process.execPath,
120122
['--input-type=module',

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-resolve-type.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ try {
198198
subdirPackageType,
199199
expectedResolvedFormat,
200200
mainSuffix = '' ] = testVariant;
201+
const skip = mainImportScript.endsWith('.ts') && !process.config.variables.node_use_amaro;
202+
if (skip) {
203+
return;
204+
}
201205

202206
const mDir = rel(`node_modules/${moduleName}`);
203207
const subDir = rel(`node_modules/${moduleName}/subdir`);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
6363
hasTrueAsDefaultValue = true;
6464
}
6565

66+
// Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available)
67+
if (config.includes('HAVE_AMARO')) {
68+
hasTrueAsDefaultValue = true;
69+
}
70+
6671
if (
6772
envVar.startsWith('[') ||
6873
deprecated.includes(envVar) ||

test/parallel/test-compile-cache-typescript-commonjs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
// This tests NODE_COMPILE_CACHE works for CommonJS with types.
44

5-
require('../common');
5+
const common = require('../common');
6+
if (!process.config.variables.node_use_amaro) {
7+
common.skip('Requires Amaro');
8+
}
69
const { spawnSyncAndAssert } = require('../common/child_process');
710
const assert = require('assert');
811
const tmpdir = require('../common/tmpdir');

test/parallel/test-compile-cache-typescript-esm.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
// This tests NODE_COMPILE_CACHE works for ESM with types.
44

5-
require('../common');
5+
const common = require('../common');
6+
if (!process.config.variables.node_use_amaro) {
7+
common.skip('Requires Amaro');
8+
}
69
const { spawnSyncAndAssert } = require('../common/child_process');
710
const assert = require('assert');
811
const tmpdir = require('../common/tmpdir');

test/parallel/test-compile-cache-typescript-strip-miss.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// This tests NODE_COMPILE_CACHE can handle cache invalidation
44
// between strip-only TypeScript and transformed TypeScript.
55

6-
require('../common');
6+
const common = require('../common');
7+
if (!process.config.variables.node_use_amaro) {
8+
common.skip('Requires Amaro');
9+
}
710
const { spawnSyncAndAssert } = require('../common/child_process');
811
const assert = require('assert');
912
const tmpdir = require('../common/tmpdir');

test/parallel/test-compile-cache-typescript-strip-sourcemaps.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// This tests NODE_COMPILE_CACHE can be used for type stripping and ignores
44
// --enable-source-maps as there's no difference in the code generated.
55

6-
require('../common');
6+
const common = require('../common');
7+
if (!process.config.variables.node_use_amaro) {
8+
common.skip('Requires Amaro');
9+
}
710
const { spawnSyncAndAssert } = require('../common/child_process');
811
const assert = require('assert');
912
const tmpdir = require('../common/tmpdir');

0 commit comments

Comments
 (0)