diff --git a/test/common/wpt.js b/test/common/wpt.js index f7a19cfec74206..d8333c19c60014 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -147,8 +147,7 @@ class WPTTestSpec { * 'test.any.js' * @param {StatusRule[]} rules */ - constructor(mod, filename, rules, version) { - this.version = version; + constructor(mod, filename, rules) { this.module = mod; this.filename = filename; @@ -161,17 +160,8 @@ class WPTTestSpec { this.requires.add(req); } } - switch (this.version) { - case 1: - if (item.fail) { - this.failReasons.push(item.fail); - } - break; - case 2: - default: - if (Array.isArray(item.fail?.expected)) { - this.failReasons.push(...item.fail.expected); - } + if (Array.isArray(item.fail?.expected)) { + this.failReasons.push(...item.fail.expected); } if (item.skip) { this.skipReasons.push(item.skip); @@ -270,7 +260,7 @@ class StatusLoader { load() { const dir = path.join(__dirname, '..', 'wpt'); const statusFile = path.join(dir, 'status', `${this.path}.json`); - const { '$version': version, ...result } = JSON.parse(fs.readFileSync(statusFile, 'utf8')); + const result = JSON.parse(fs.readFileSync(statusFile, 'utf8')); this.rules.addRules(result); const subDir = fixtures.path('wpt', this.path); @@ -278,7 +268,7 @@ class StatusLoader { for (const file of list) { const relativePath = path.relative(subDir, file); const match = this.rules.match(relativePath); - this.specs.push(new WPTTestSpec(this.path, relativePath, match, version)); + this.specs.push(new WPTTestSpec(this.path, relativePath, match)); } this.loaded = true; } @@ -479,7 +469,7 @@ class WPTRunner { } } inspect.defaultOptions.depth = Infinity; - // sorts the rules to have consistent output + // Sorts the rules to have consistent output console.log(JSON.stringify(Object.keys(this.results).sort().reduce( (obj, key) => { obj[key] = this.results[key]; @@ -606,18 +596,10 @@ class WPTRunner { fail(filename, test, status) { const spec = this.specMap.get(filename); - let expected; - switch (spec.version) { - case 1: - expected = !!(spec.failReasons.length); - break; - case 2: - default: - expected = spec.failReasons.includes(test.message || reason); - } + const expected = spec.failReasons.includes(test.message || status); if (expected) { console.log(`[EXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`); - console.log(test.message || reason); + console.log(test.message || status); } else { console.log(`[UNEXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`); } diff --git a/test/wpt/README.md b/test/wpt/README.md index b8ded27ef37d78..0bb43be81703e5 100644 --- a/test/wpt/README.md +++ b/test/wpt/README.md @@ -91,7 +91,11 @@ add this to `test/wpt/status/url.json`: ```json "url-searchparams.any.js": { - "fail": "explain why the test fails, ideally with links" + "fail": { + "expected": [ + "exhibited error message" + ] + } } ``` @@ -155,8 +159,12 @@ expected failures. // Optional: the test will be skipped with the reason printed "skip": "explain why we cannot run a test that's supposed to pass", - // Optional: the test will be skipped with the reason printed - "fail": "explain why we the test is expected to fail" + // Optional: tests failing with this message are expected + "fail": { + "expected": [ + "exhibited error message" + ] + } } } ```