Skip to content

Commit

Permalink
test: allow test names in WPT Status expected failures
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jun 17, 2022
1 parent 2804b84 commit 5f255de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions test/common/wpt.js
Expand Up @@ -152,7 +152,7 @@ class WPTTestSpec {
this.filename = filename;

this.requires = new Set();
this.failReasons = [];
this.failedTests = [];
this.skipReasons = [];
for (const item of rules) {
if (item.requires.length) {
Expand All @@ -161,7 +161,7 @@ class WPTTestSpec {
}
}
if (Array.isArray(item.fail?.expected)) {
this.failReasons.push(...item.fail.expected);
this.failedTests.push(...item.fail.expected);
}
if (item.skip) {
this.skipReasons.push(item.skip);
Expand Down Expand Up @@ -584,7 +584,9 @@ class WPTRunner {
if (!result[item.status][key]) {
result[item.status][key] = [];
}
if (result[item.status][key].indexOf(item.reason) === -1) {
const hasName = result[item.status][key].includes(item.name)
const hasReason = result[item.status][key].includes(item.reason)
if (!hasName && !hasReason) {
result[item.status][key].push(item.reason);
}
}
Expand All @@ -596,7 +598,7 @@ class WPTRunner {

fail(filename, test, status) {
const spec = this.specMap.get(filename);
const expected = spec.failReasons.includes(test.message || status);
const expected = spec.failedTests.includes(test.name) || spec.failedTests.includes(test.message || status);
if (expected) {
console.log(`[EXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`);
console.log(test.message || status);
Expand All @@ -611,6 +613,7 @@ class WPTRunner {
` ${require.main.filename} ${filename}`;
console.log(`Command: ${command}\n`);
this.addTestResult(filename, {
name: test.name,
expected,
status: kFail,
reason: test.message || status
Expand Down
6 changes: 4 additions & 2 deletions test/wpt/README.md
Expand Up @@ -93,7 +93,7 @@ add this to `test/wpt/status/url.json`:
"url-searchparams.any.js": {
"fail": {
"expected": [
"exhibited error message"
"test name"
]
}
}
Expand Down Expand Up @@ -162,7 +162,9 @@ expected failures.
// Optional: tests failing with this message are expected
"fail": {
"expected": [
"exhibited error message"
"exhibited error message",
// or
"test name"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/wpt/status/html/webappapis/atob.json
Expand Up @@ -2,7 +2,7 @@
"base64.any.js": {
"fail": {
"expected": [
"promise_test: Unhandled rejection with value: object \"Error: ENOENT: no such file or directory, open '/Users/panva/repo/node/test/fixtures/wpt/fetch/data-urls/resources/base64.json'\""
"atob() setup."
]
}
}
Expand Down

0 comments on commit 5f255de

Please sign in to comment.