-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
test: skip failing tests and set the default value of strip-types to false when compiled without amaro #60815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
|
Good job 👍🏼 We can skip just the failing subtest, you can pass an argument |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60815 +/- ##
==========================================
- Coverage 88.56% 88.53% -0.03%
==========================================
Files 703 703
Lines 208268 208268
Branches 40175 40179 +4
==========================================
- Hits 184444 184399 -45
- Misses 15828 15878 +50
+ Partials 7996 7991 -5
🚀 New features to boost your workflow:
|
|
That's great, I'll be glad to test when it's ready and before it's merged. |
test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs
Outdated
Show resolved
Hide resolved
When compiled without amaro, this conflicts with --experimental-strip-types defaulting to true. To avoid that, we need to skip relevant failing tests. Fixes: nodejs#60640
stripe-types option's default value is true, but we need to ensure that when compiled without amaro, the default vaue is false. Fixes: nodejs#60640
Move the amaro availability check immediately after importing common module in test files, as requested in PR feedback. Changes: - Place amaro check after common import but before other imports - Update test-node-output-sourcemaps.mjs to dynamically skip .ts tests based on file extension - Add individual skip conditions for TypeScript-specific tests - Fix linting errors (missing semicolon, line length issues) Refs: nodejs#60815
…ne pass fixed the test failure due to its changeable default value. Fixes: nodejs#60640
a450ee5 to
3dc852d
Compare
|
Thank you very much for your reviews. I addressed the points. Could you please take a look again? Thank you in advance! |
| // Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available) | ||
| if (config.includes('HAVE_AMARO')) { | ||
| hasTrueAsDefaultValue = true; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is added because the value of HAVE_AMARO is changeable (the default is true), and this test can't deal with that. Rather than adding a complex logic like checking #if in config (which is not 100% correct because, like in this case, changeable variables such as HAVE_AMARO can be assigned instead of using #if), I added this logic instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant we use process.config.variables.node_use_amaro ?
| assert.strictEqual(code, 1); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| it('still throws on `await` in an ordinary sync function', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be related to amaro 🤔 why is it failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I think this is related to amaro, because eval used in this test calls evalTypeScript (code), which is triggered by --strip-types option (code). Even when compiled without amaro, this means that the defalut value of --strip-types will be false, but the users can manipulate this values by setting true. Thus, as long as TypeScript type stripping is triggered due to --strip-types, skipping this test sounds good to me. What do you think?
This is the error message:
Details
=== release test-esm-detect-ambiguous === Path: es-module/test-esm-detect-ambiguous Test failure: 'still throws on `await` in an ordinary sync function' Location: test/es-module/test-esm-detect-ambiguous.mjs:266:5 AssertionError [ERR_ASSERTION]: The input did not match the regular expression /SyntaxError: await is only valid in async function/. Input:
'node:internal/process/execution:279\n' +
' throw tsError;\n' +
' ^\n' +
'\n' +
'Error [ERR_NO_TYPESCRIPT]: Node.js is not compiled with TypeScript support\n' +
' at assertTypeScript (node:internal/util:244:11)\n' +
' at node:internal/modules/typescript:46:3\n' +
' at node:internal/util:801:15\n' +
' at parseTypeScript (node:internal/modules/typescript:58:17)\n' +
' at processTypeScriptCode (node:internal/modules/typescript:146:42)\n' +
' at stripTypeScriptModuleTypes (node:internal/modules/typescript:209:22)\n' +
' at evalTypeScript (node:internal/process/execution:263:21)\n' +
' at node:internal/main/eval_string:71:3 {\n' +
" code: 'ERR_NO_TYPESCRIPT'\n" +
'}\n' +
'\n' +
'Node.js v26.0.0-pre\n'
at TestContext.<anonymous> (file:///Users/y-okt/ghq/github.com/y-okt/node/test/es-module/test-esm-detect-ambiguous.mjs:272:14)
at async Test.run (node:internal/test_runner/test:1102:7)
at async Suite.processPendingSubtests (node:internal/test_runner/test:777:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 'node:internal/process/execution:279\n' +
' throw tsError;\n' +
' ^\n' +
'\n' +
'Error [ERR_NO_TYPESCRIPT]: Node.js is not compiled with TypeScript support\n' +
' at assertTypeScript (node:internal/util:244:11)\n' +
' at node:internal/modules/typescript:46:3\n' +
' at node:internal/util:801:15\n' +
' at parseTypeScript (node:internal/modules/typescript:58:17)\n' +
' at processTypeScriptCode (node:internal/modules/typescript:146:42)\n' +
'...',
expected: /SyntaxError: await is only valid in async function/,
operator: 'match',
diff: 'simple'
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but in this test we are not manually setting --strip-types to true, and since now is set to default false it should not fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out why: we have to set bool strip_types = false; otherwise even if HAVE_AMARO is false it will also be true
diff --git a/src/node_options.h b/src/node_options.h
index dd782b460ae..57a828de614 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -259,7 +259,7 @@ class EnvironmentOptions : public Options {
std::vector<std::string> preload_esm_modules;
- bool strip_types = true;
+ bool strip_types = false;
bool experimental_transform_types = false;
std::vector<std::string> user_argv;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't false disable it for everyone?
diff --git a/src/node_options.h b/src/node_options.h
index dd782b460ae..57a828de614 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -259,7 +259,7 @@ class EnvironmentOptions : public Options {
std::vector<std::string> preload_esm_modules;
- bool strip_types = true;
+ bool strip_types = HAVE_AMARO;
bool experimental_transform_types = false;
std::vector<std::string> user_argv;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because the default: true in AddOption overrides it.
But also that works
| test('Worker eval module typescript without input-type', | ||
| { skip: !process.config.variables.node_use_amaro }, | ||
| async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make the diff more readable by using a variable
| test('Worker eval module typescript without input-type', | |
| { skip: !process.config.variables.node_use_amaro }, | |
| async () => { | |
| const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; | |
| test('Worker eval module typescript without input-type', onlyWithAmaro, async () => { |
|
Once we fix #60815 (comment) |
Summary
This PR is to address #60640 . When compiled without amaro, some tests fail. This is because
--strip-typesoption should default to false when compiled without amaro, but it is set to true now. As suggested by @marco-ippolito , this PR addresses this issue by--strip-typesto false ifHAVE_AMAROis not trueBackground
Amaro is a wrapper around
@swc/wasm-typescript, and is used internally in Node.js for Type Stripping. When compiled without amaro, Type Stripping functionalities are not available internally. However, because--strip-typesdefault value is true, some tests fail under that situation.The suggested fix is as aforementioned, 1) skip the failing tests when the option is false, and set its default value to false when compiled without amaro.
Regarding the failing tests, the list below is the full list of the failing tests due to Amaro. When running with amaro, all the tests passed, and when running without amaro, the tests below failed, meaning that test failures are attributed to the existence of amaro.
Also, I confirmed that these tests are failing not due to flakiness, but amaro. Most of the failures were with the
Error [ERR_NO_TYPESCRIPT]: Node.js is not compiled with TypeScript supporterror message. For the files which don't have this error message, the reason it's relevant to amaro is written below respectively.List of failing tests when compiled without amaro:
file.test.tsNote that the environment in which this was confirmed is M4 Mac and OS is Sequoia 15.3.2.