From 8d8c30599a25af55feb7e761b1bcf654c1d44d52 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 2 Jan 2019 23:52:38 +0800 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/25321 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/common/wpt.js | 48 +++++++++++++++++++++++++++++++++++----- test/wpt/README.md | 2 +- test/wpt/status/url.json | 4 ++-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/test/common/wpt.js b/test/common/wpt.js index de8dd0fc428e4e..0b4424ef73b224 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -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; @@ -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; @@ -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; } diff --git a/test/wpt/README.md b/test/wpt/README.md index ff9092e6a1acd9..15318b2aefe5d7 100644 --- a/test/wpt/README.md +++ b/test/wpt/README.md @@ -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", diff --git a/test/wpt/status/url.json b/test/wpt/status/url.json index 42b5f6fb1a1146..fa27b25abdb54c 100644 --- a/test/wpt/status/url.json +++ b/test/wpt/status/url.json @@ -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"