Skip to content

Commit 8d8c305

Browse files
joyeecheungaddaleax
authored andcommitted
test: support more icu requirements in the WPT status file
Support `small-icu` and `full-icu` requirements, where `full-icu` implies `small-icu`. PR-URL: #25321 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent d9adcee commit 8d8c305

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

test/common/wpt.js

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
/* eslint-disable node-core/required-modules */
12
'use strict';
23

34
const assert = require('assert');
4-
const common = require('../common');
55
const fixtures = require('../common/fixtures');
66
const fs = require('fs');
77
const fsPromises = fs.promises;
@@ -160,12 +160,49 @@ class WPTTest {
160160
getContent() {
161161
return fs.readFileSync(this.getAbsolutePath(), 'utf8');
162162
}
163+
}
164+
165+
const kIntlRequirement = {
166+
none: 0,
167+
small: 1,
168+
full: 2,
169+
// TODO(joyeecheung): we may need to deal with --with-intl=system-icu
170+
};
171+
172+
class IntlRequirement {
173+
constructor() {
174+
this.currentIntl = kIntlRequirement.none;
175+
if (process.config.variables.v8_enable_i18n_support === 0) {
176+
this.currentIntl = kIntlRequirement.none;
177+
return;
178+
}
179+
// i18n enabled
180+
if (process.config.variables.icu_small) {
181+
this.currentIntl = kIntlRequirement.small;
182+
} else {
183+
this.currentIntl = kIntlRequirement.full;
184+
}
185+
}
163186

164-
requireIntl() {
165-
return this.requires.has('intl');
187+
/**
188+
* @param {Set} requires
189+
* @returns {string|false} The config that the build is lacking, or false
190+
*/
191+
isLacking(requires) {
192+
const current = this.currentIntl;
193+
if (requires.has('full-icu') && current !== kIntlRequirement.full) {
194+
return 'full-icu';
195+
}
196+
if (requires.has('small-icu') && current < kIntlRequirement.small) {
197+
return 'small-icu';
198+
}
199+
return false;
166200
}
167201
}
168202

203+
const intlRequirements = new IntlRequirement();
204+
205+
169206
class StatusLoader {
170207
constructor(path) {
171208
this.path = path;
@@ -498,8 +535,9 @@ class WPTRunner {
498535
continue;
499536
}
500537

501-
if (!common.hasIntl && test.requireIntl()) {
502-
this.skip(filename, [ 'missing Intl' ]);
538+
const lackingIntl = intlRequirements.isLacking(test.requires);
539+
if (lackingIntl) {
540+
this.skip(filename, [ `requires ${lackingIntl}` ]);
503541
continue;
504542
}
505543

test/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ expected failures.
151151
{
152152
"something.scope.js": { // the file name
153153
// Optional: If the requirement is not met, this test will be skipped
154-
"requires": ["intl"], // currently only intl is supported
154+
"requires": ["small-icu"], // supports: "small-icu", "full-icu"
155155
156156
// Optional: the test will be skipped with the reason printed
157157
"skip": "explain why we cannot run a test that's supposed to pass",

test/wpt/status/url.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"toascii.window.js": {
3-
"requires": ["intl"],
3+
"requires": ["small-icu"],
44
"skip": "TODO: port from .window.js"
55
},
66
"historical.any.js": {
7-
"requires": ["intl"]
7+
"requires": ["small-icu"]
88
},
99
"urlencoded-parser.any.js": {
1010
"fail": "missing Request and Response"

0 commit comments

Comments
 (0)