Skip to content
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

test: fix intl tests on small-icu builds #41939

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ if (!common.hasIntl) {
const numberFormat = new Intl.NumberFormat(['en']).format(12345.67890);
assert.strictEqual(numberFormat, '12,345.679');
}
// If list is specified and doesn't contain 'en-US' then return.
if (process.config.variables.icu_locales && !haveLocale('en-US')) {
targos marked this conversation as resolved.
Show resolved Hide resolved
common.printSkipMessage(
'detailed Intl tests because Node.js was built with small ICU.');
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not common.skip() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I copied it from

// If list is specified and doesn't contain 'en' then return.
if (process.config.variables.icu_locales && !haveLocale('en')) {
common.printSkipMessage(
'detailed Intl tests because English is not listed as supported.');
// Smoke test. Does it format anything, or fail?
console.log(`Date(0) formatted to: ${dtf.format(date0)}`);
return;

Copy link
Member

@Trott Trott Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe common.skip() is for skipping everything in the file as it exits immediately, but common.printSkipMessage() can be used if you're just skipping a single test case in a file as it only prints a TAP message. But, uh, it's been a while since I've had to actually know how they worked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true, but the return; here effectively ends the test file.

}
// Number format resolved options
{
const numberFormat = new Intl.NumberFormat('en-US', { style: 'percent' });
Expand Down