Skip to content

Commit

Permalink
test: support more icu requirements in the WPT status file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
joyeecheung committed Jan 10, 2019
1 parent 8906e52 commit c667325
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
48 changes: 43 additions & 5 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable node-core/required-modules */
'use strict';

const assert = require('assert');
const common = require('../common');
const fixtures = require('../common/fixtures');
const fs = require('fs');
const fsPromises = fs.promises;
Expand Down Expand Up @@ -160,12 +160,49 @@ class WPTTest {
getContent() {
return fs.readFileSync(this.getAbsolutePath(), 'utf8');
}
}

const kIntlRequirement = {
none: 0,
small: 1,
full: 2,
// TODO(joyeecheung): we may need to deal with --with-intl=system-icu
};

class IntlRequirement {
constructor() {
this.currentIntl = kIntlRequirement.none;
if (process.config.variables.v8_enable_i18n_support === 0) {
this.currentIntl = kIntlRequirement.none;
return;
}
// i18n enabled
if (process.config.variables.icu_small) {
this.currentIntl = kIntlRequirement.small;
} else {
this.currentIntl = kIntlRequirement.full;
}
}

requireIntl() {
return this.requires.has('intl');
/**
* @param {Set} requires
* @returns {string|false} The config that the build is lacking, or false
*/
isLacking(requires) {
const current = this.currentIntl;
if (requires.has('full-icu') && current !== kIntlRequirement.full) {
return 'full-icu';
}
if (requires.has('small-icu') && current < kIntlRequirement.small) {
return 'small-icu';
}
return false;
}
}

const intlRequirements = new IntlRequirement();


class StatusLoader {
constructor(path) {
this.path = path;
Expand Down Expand Up @@ -498,8 +535,9 @@ class WPTRunner {
continue;
}

if (!common.hasIntl && test.requireIntl()) {
this.skip(filename, [ 'missing Intl' ]);
const lackingIntl = intlRequirements.isLacking(test.requires);
if (lackingIntl) {
this.skip(filename, [ `requires ${lackingIntl}` ]);
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion test/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ expected failures.
{
"something.scope.js": { // the file name
// Optional: If the requirement is not met, this test will be skipped
"requires": ["intl"], // currently only intl is supported
"requires": ["small-icu"], // supports: "small-icu", "full-icu"
// Optional: the test will be skipped with the reason printed
"skip": "explain why we cannot run a test that's supposed to pass",
Expand Down
4 changes: 2 additions & 2 deletions test/wpt/status/url.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"toascii.window.js": {
"requires": ["intl"],
"requires": ["small-icu"],
"skip": "TODO: port from .window.js"
},
"historical.any.js": {
"requires": ["intl"]
"requires": ["small-icu"]
},
"urlencoded-parser.any.js": {
"fail": "missing Request and Response"
Expand Down

0 comments on commit c667325

Please sign in to comment.