| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const fixtures = require('../common/fixtures'); | |||
| 5 | 5 | const fs = require('fs'); | |
| 6 | 6 | const fsPromises = fs.promises; | |
| 7 | 7 | const path = require('path'); | |
| 8 | + const events = require('events'); | ||
| 8 | 9 | const { inspect } = require('util'); | |
| 9 | 10 | const { Worker } = require('worker_threads'); | |
| 10 | 11 | ||
@@ -152,21 +153,30 @@ class WPTTestSpec { | |||
| 152 | 153 | this.filename = filename; | |
| 153 | 154 | ||
| 154 | 155 | this.requires = new Set(); | |
| 155 | - this.failReasons = []; | ||
| 156 | + this.failedTests = []; | ||
| 157 | + this.flakyTests = []; | ||
| 156 | 158 | this.skipReasons = []; | |
| 157 | 159 | for (const item of rules) { | |
| 158 | 160 | if (item.requires.length) { | |
| 159 | 161 | for (const req of item.requires) { | |
| 160 | 162 | this.requires.add(req); | |
| 161 | 163 | } | |
| 162 | 164 | } | |
| 163 | - if (item.fail) { | ||
| 164 | - this.failReasons.push(item.fail); | ||
| 165 | + if (Array.isArray(item.fail?.expected)) { | ||
| 166 | + this.failedTests.push(...item.fail.expected); | ||
| 167 | + } | ||
| 168 | + if (Array.isArray(item.fail?.flaky)) { | ||
| 169 | + this.failedTests.push(...item.fail.flaky); | ||
| 170 | + this.flakyTests.push(...item.fail.flaky); | ||
| 165 | 171 | } | |
| 166 | 172 | if (item.skip) { | |
| 167 | 173 | this.skipReasons.push(item.skip); | |
| 168 | 174 | } | |
| 169 | 175 | } | |
| 176 | + | ||
| 177 | + this.failedTests = [...new Set(this.failedTests)]; | ||
| 178 | + this.flakyTests = [...new Set(this.flakyTests)]; | ||
| 179 | + this.skipReasons = [...new Set(this.skipReasons)]; | ||
| 170 | 180 | } | |
| 171 | 181 | ||
| 172 | 182 | getRelativePath() { | |
@@ -368,7 +378,7 @@ class WPTRunner { | |||
| 368 | 378 | ||
| 369 | 379 | // TODO(joyeecheung): work with the upstream to port more tests in .html | |
| 370 | 380 | // to .js. | |
| 371 | - runJsTests() { | ||
| 381 | + async runJsTests() { | ||
| 372 | 382 | let queue = []; | |
| 373 | 383 | ||
| 374 | 384 | // If the tests are run as `node test/wpt/test-something.js subset.any.js`, | |
@@ -459,6 +469,8 @@ class WPTRunner { | |||
| 459 | 469 | ); | |
| 460 | 470 | this.inProgress.delete(testFileName); | |
| 461 | 471 | }); | |
| 472 | + | ||
| 473 | + await events.once(worker, 'exit').catch(() => {}); | ||
| 462 | 474 | } | |
| 463 | 475 | ||
| 464 | 476 | process.on('exit', () => { | |
@@ -469,34 +481,72 @@ class WPTRunner { | |||
| 469 | 481 | } | |
| 470 | 482 | } | |
| 471 | 483 | inspect.defaultOptions.depth = Infinity; | |
| 472 | - console.log(this.results); | ||
| 484 | + // Sorts the rules to have consistent output | ||
| 485 | + console.log(JSON.stringify(Object.keys(this.results).sort().reduce( | ||
| 486 | + (obj, key) => { | ||
| 487 | + obj[key] = this.results[key]; | ||
| 488 | + return obj; | ||
| 489 | + }, | ||
| 490 | + {} | ||
| 491 | + ), null, 2)); | ||
| 473 | 492 | ||
| 474 | 493 | const failures = []; | |
| 475 | 494 | let expectedFailures = 0; | |
| 476 | 495 | let skipped = 0; | |
| 477 | - for (const key of Object.keys(this.results)) { | ||
| 478 | - const item = this.results[key]; | ||
| 479 | - if (item.fail && item.fail.unexpected) { | ||
| 496 | + for (const [key, item] of Object.entries(this.results)) { | ||
| 497 | + if (item.fail?.unexpected) { | ||
| 480 | 498 | failures.push(key); | |
| 481 | 499 | } | |
| 482 | - if (item.fail && item.fail.expected) { | ||
| 500 | + if (item.fail?.expected) { | ||
| 483 | 501 | expectedFailures++; | |
| 484 | 502 | } | |
| 485 | 503 | if (item.skip) { | |
| 486 | 504 | skipped++; | |
| 487 | 505 | } | |
| 488 | 506 | } | |
| 507 | + | ||
| 508 | + const unexpectedPasses = []; | ||
| 509 | + for (const [key, specMap] of this.specMap) { | ||
| 510 | + // File has no expected failures | ||
| 511 | + if (!specMap.failedTests.length) { | ||
| 512 | + continue; | ||
| 513 | + } | ||
| 514 | + | ||
| 515 | + // File was (maybe even conditionally) skipped | ||
| 516 | + if (this.results[key]?.skip) { | ||
| 517 | + continue; | ||
| 518 | + } | ||
| 519 | + | ||
| 520 | + // Full check: every expected to fail test is present | ||
| 521 | + if (specMap.failedTests.some((expectedToFail) => { | ||
| 522 | + if (specMap.flakyTests.includes(expectedToFail)) { | ||
| 523 | + return false; | ||
| 524 | + } | ||
| 525 | + return this.results[key]?.fail?.expected?.includes(expectedToFail) !== true; | ||
| 526 | + })) { | ||
| 527 | + unexpectedPasses.push(key); | ||
| 528 | + continue; | ||
| 529 | + } | ||
| 530 | + } | ||
| 531 | + | ||
| 489 | 532 | const ran = total - skipped; | |
| 490 | 533 | const passed = ran - expectedFailures - failures.length; | |
| 491 | 534 | console.log(`Ran ${ran}/${total} tests, ${skipped} skipped,`, | |
| 492 | 535 | `${passed} passed, ${expectedFailures} expected failures,`, | |
| 493 | - `${failures.length} unexpected failures`); | ||
| 536 | + `${failures.length} unexpected failures,`, | ||
| 537 | + `${unexpectedPasses.length} unexpected passes`); | ||
| 494 | 538 | if (failures.length > 0) { | |
| 495 | 539 | const file = path.join('test', 'wpt', 'status', `${this.path}.json`); | |
| 496 | 540 | throw new Error( | |
| 497 | 541 | `Found ${failures.length} unexpected failures. ` + | |
| 498 | 542 | `Consider updating ${file} for these files:\n${failures.join('\n')}`); | |
| 499 | 543 | } | |
| 544 | + if (unexpectedPasses.length > 0) { | ||
| 545 | + const file = path.join('test', 'wpt', 'status', `${this.path}.json`); | ||
| 546 | + throw new Error( | ||
| 547 | + `Found ${unexpectedPasses.length} unexpected passes. ` + | ||
| 548 | + `Consider updating ${file} for these files:\n${unexpectedPasses.join('\n')}`); | ||
| 549 | + } | ||
| 500 | 550 | }); | |
| 501 | 551 | } | |
| 502 | 552 | ||
@@ -577,8 +627,9 @@ class WPTRunner { | |||
| 577 | 627 | if (!result[item.status][key]) { | |
| 578 | 628 | result[item.status][key] = []; | |
| 579 | 629 | } | |
| 580 | - if (result[item.status][key].indexOf(item.reason) === -1) { | ||
| 581 | - result[item.status][key].push(item.reason); | ||
| 630 | + const hasName = result[item.status][key].includes(item.name); | ||
| 631 | + if (!hasName) { | ||
| 632 | + result[item.status][key].push(item.name); | ||
| 582 | 633 | } | |
| 583 | 634 | } | |
| 584 | 635 | } | |
@@ -589,10 +640,10 @@ class WPTRunner { | |||
| 589 | 640 | ||
| 590 | 641 | fail(filename, test, status) { | |
| 591 | 642 | const spec = this.specMap.get(filename); | |
| 592 | - const expected = !!(spec.failReasons.length); | ||
| 643 | + const expected = spec.failedTests.includes(test.name); | ||
| 593 | 644 | if (expected) { | |
| 594 | 645 | console.log(`[EXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`); | |
| 595 | - console.log(spec.failReasons.join('; ')); | ||
| 646 | + console.log(test.message || status); | ||
| 596 | 647 | } else { | |
| 597 | 648 | console.log(`[UNEXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`); | |
| 598 | 649 | } | |
@@ -604,6 +655,7 @@ class WPTRunner { | |||
| 604 | 655 | ` ${require.main.filename} ${filename}`; | |
| 605 | 656 | console.log(`Command: ${command}\n`); | |
| 606 | 657 | this.addTestResult(filename, { | |
| 658 | + name: test.name, | ||
| 607 | 659 | expected, | |
| 608 | 660 | status: kFail, | |
| 609 | 661 | reason: test.message || status | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,11 @@ add this to `test/wpt/status/url.json`: | |||
| 91 | 91 | ||
| 92 | 92 | ```json | |
| 93 | 93 | "url-searchparams.any.js": { | |
| 94 | - "fail": "explain why the test fails, ideally with links" | ||
| 94 | + "fail": { | ||
| 95 | + "expected": [ | ||
| 96 | + "test name in the WPT test case, e.g. second argument passed to test()" | ||
| 97 | + ] | ||
| 98 | + } | ||
| 95 | 99 | } | |
| 96 | 100 | ``` | |
| 97 | 101 | ||
@@ -155,8 +159,17 @@ expected failures. | |||
| 155 | 159 | // Optional: the test will be skipped with the reason printed | |
| 156 | 160 | "skip": "explain why we cannot run a test that's supposed to pass", | |
| 157 | 161 | ||
| 158 | - // Optional: the test will be skipped with the reason printed | ||
| 159 | - "fail": "explain why we the test is expected to fail" | ||
| 162 | + // Optional: failing tests | ||
| 163 | + "fail": { | ||
| 164 | + "note": "You may leave an optional arbitrary note e.g. with TODOs", | ||
| 165 | + "expected": [ | ||
| 166 | + "test name in the WPT test case, e.g. second argument passed to test()", | ||
| 167 | + "another test name" | ||
| 168 | + ], | ||
| 169 | + "flaky": [ | ||
| 170 | + "flaky test name" | ||
| 171 | + ] | ||
| 172 | + } | ||
| 160 | 173 | } | |
| 161 | 174 | } | |
| 162 | 175 | ``` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,47 @@ | |||
| 1 | 1 | { | |
| 2 | - "Blob-constructor.any.js": { | ||
| 3 | - "skip": "Depends on File API" | ||
| 4 | - }, | ||
| 5 | 2 | "Blob-constructor-dom.window.js": { | |
| 6 | 3 | "skip": "Depends on DOM API" | |
| 7 | 4 | }, | |
| 8 | - "Blob-slice.any.js": { | ||
| 9 | - "skip": "Depends on File API" | ||
| 5 | + "Blob-constructor.any.js": { | ||
| 6 | + "fail": { | ||
| 7 | + "note": "Depends on File API", | ||
| 8 | + "expected": [ | ||
| 9 | + "A plain object with @@iterator should be treated as a sequence for the blobParts argument.", | ||
| 10 | + "A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument.", | ||
| 11 | + "A String object should be treated as a sequence for the blobParts argument.", | ||
| 12 | + "A Uint8Array object should be treated as a sequence for the blobParts argument.", | ||
| 13 | + "Getters and value conversions should happen in order until an exception is thrown.", | ||
| 14 | + "Changes to the blobParts array should be reflected in the returned Blob (pop).", | ||
| 15 | + "Changes to the blobParts array should be reflected in the returned Blob (unshift).", | ||
| 16 | + "ToString should be called on elements of the blobParts array.", | ||
| 17 | + "ArrayBuffer elements of the blobParts array should be supported.", | ||
| 18 | + "Passing typed arrays as elements of the blobParts array should work.", | ||
| 19 | + "Passing a Float64Array as element of the blobParts array should work.", | ||
| 20 | + "Array with two blobs", | ||
| 21 | + "Array with two buffers", | ||
| 22 | + "Array with two bufferviews", | ||
| 23 | + "Array with mixed types", | ||
| 24 | + "options properties should be accessed in lexicographic order.", | ||
| 25 | + "Arguments should be evaluated from left to right.", | ||
| 26 | + "Passing null (index 0) for options should use the defaults.", | ||
| 27 | + "Passing null (index 0) for options should use the defaults (with newlines).", | ||
| 28 | + "Passing undefined (index 1) for options should use the defaults.", | ||
| 29 | + "Passing undefined (index 1) for options should use the defaults (with newlines).", | ||
| 30 | + "Passing object \"[object Object]\" (index 2) for options should use the defaults.", | ||
| 31 | + "Passing object \"[object Object]\" (index 2) for options should use the defaults (with newlines).", | ||
| 32 | + "Passing object \"[object Object]\" (index 3) for options should use the defaults.", | ||
| 33 | + "Passing object \"[object Object]\" (index 3) for options should use the defaults (with newlines).", | ||
| 34 | + "Passing object \"/regex/\" (index 4) for options should use the defaults.", | ||
| 35 | + "Passing object \"/regex/\" (index 4) for options should use the defaults (with newlines).", | ||
| 36 | + "Passing function \"function() {}\" (index 5) for options should use the defaults.", | ||
| 37 | + "Passing function \"function() {}\" (index 5) for options should use the defaults (with newlines)." | ||
| 38 | + ] | ||
| 39 | + } | ||
| 10 | 40 | }, | |
| 11 | 41 | "Blob-in-worker.worker.js": { | |
| 12 | 42 | "skip": "Depends on Web Workers API" | |
| 43 | + }, | ||
| 44 | + "Blob-slice.any.js": { | ||
| 45 | + "skip": "Depends on File API" | ||
| 13 | 46 | } | |
| 14 | 47 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments