Skip to content

Commit 3eacbf6

Browse files
committed
test: remove old behaviour from WPT runner
1 parent 5057cac commit 3eacbf6

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

test/common/wpt.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ class WPTTestSpec {
147147
* 'test.any.js'
148148
* @param {StatusRule[]} rules
149149
*/
150-
constructor(mod, filename, rules, version) {
151-
this.version = version;
150+
constructor(mod, filename, rules) {
152151
this.module = mod;
153152
this.filename = filename;
154153

@@ -161,17 +160,8 @@ class WPTTestSpec {
161160
this.requires.add(req);
162161
}
163162
}
164-
switch (this.version) {
165-
case 1:
166-
if (item.fail) {
167-
this.failReasons.push(item.fail);
168-
}
169-
break;
170-
case 2:
171-
default:
172-
if (Array.isArray(item.fail?.expected)) {
173-
this.failReasons.push(...item.fail.expected);
174-
}
163+
if (Array.isArray(item.fail?.expected)) {
164+
this.failReasons.push(...item.fail.expected);
175165
}
176166
if (item.skip) {
177167
this.skipReasons.push(item.skip);
@@ -270,15 +260,15 @@ class StatusLoader {
270260
load() {
271261
const dir = path.join(__dirname, '..', 'wpt');
272262
const statusFile = path.join(dir, 'status', `${this.path}.json`);
273-
const { '$version': version, ...result } = JSON.parse(fs.readFileSync(statusFile, 'utf8'));
263+
const result = JSON.parse(fs.readFileSync(statusFile, 'utf8'));
274264
this.rules.addRules(result);
275265

276266
const subDir = fixtures.path('wpt', this.path);
277267
const list = this.grep(subDir);
278268
for (const file of list) {
279269
const relativePath = path.relative(subDir, file);
280270
const match = this.rules.match(relativePath);
281-
this.specs.push(new WPTTestSpec(this.path, relativePath, match, version));
271+
this.specs.push(new WPTTestSpec(this.path, relativePath, match));
282272
}
283273
this.loaded = true;
284274
}
@@ -606,15 +596,7 @@ class WPTRunner {
606596

607597
fail(filename, test, status) {
608598
const spec = this.specMap.get(filename);
609-
let expected;
610-
switch (spec.version) {
611-
case 1:
612-
expected = !!(spec.failReasons.length);
613-
break;
614-
case 2:
615-
default:
616-
expected = spec.failReasons.includes(test.message || reason);
617-
}
599+
const expected = spec.failReasons.includes(test.message || reason);
618600
if (expected) {
619601
console.log(`[EXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`);
620602
console.log(test.message || reason);

test/wpt/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ add this to `test/wpt/status/url.json`:
9191

9292
```json
9393
"url-searchparams.any.js": {
94-
"fail": "explain why the test fails, ideally with links"
94+
"fail": {
95+
"expected": [
96+
"exhibited error message"
97+
]
98+
}
9599
}
96100
```
97101

@@ -155,8 +159,12 @@ expected failures.
155159
// Optional: the test will be skipped with the reason printed
156160
"skip": "explain why we cannot run a test that's supposed to pass",
157161
158-
// Optional: the test will be skipped with the reason printed
159-
"fail": "explain why we the test is expected to fail"
162+
// Optional: tests failing with this message are expected
163+
"fail": {
164+
"expected": [
165+
"exhibited error message"
166+
]
167+
}
160168
}
161169
}
162170
```

0 commit comments

Comments
 (0)