-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPT: Autogenerate a test case for each test file #3076
Open
npaun
wants to merge
2
commits into
main
Choose a base branch
from
npaun/wpt-test-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+442
−344
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## How to add WPT test suites to workerd | ||
|
||
[WPT groups its test suites into directories](https://github.com/web-platform-tests/wpt). To add a new test suite to workerd, simply create a file named `suite-test-config.js`. For example, `url/` tests are added in the `url-test-config.js` file. | ||
|
||
A test config file is expected to export an object named `config`. This object can be empty to run all tests and subtests. | ||
|
||
```js | ||
export const config = {}; | ||
``` | ||
|
||
A test export is generated for each JS file in the directory. WPT test files are sometimes located in subdirectories, but the test importer flattens the hierarchy within the test suite. | ||
|
||
Each test file can contain several subtests, created by invoking `test` or `promise_test` within the test file. They are named according to the message argument provided. | ||
|
||
## Options | ||
|
||
Each entry in the `config` object specifies the test file name, and the options to apply to those tests. For example, `urlsearchparams-sort.any.js` can be configured using: | ||
|
||
```js | ||
export const config = { | ||
'urlsearchparams-sort.any.js': { | ||
expectedFailures: ['Parse and sort: ffi&🌈', 'URL parse and sort: ffi&🌈'], | ||
}, | ||
}; | ||
``` | ||
|
||
|
||
The following options are currently supported: | ||
|
||
* `ignore: bool`: Don't import a test file that is irrelevant for workerd tests | ||
* `skippedTests: string[]`: A list of subtests that should not be executed. This should only be used for subtests that would crash workerd. | ||
* `expectedFailures: string[]`: A list of subtests that are expected to fail, either due to a bug in workerd or an intentional choice not to support a feature. | ||
|
||
## Implementation | ||
|
||
Once a test config file is detected, the `wpt_test` macro is invoked for the suite. A JS test file is created that invokes the test harness on each JS file within the suite. | ||
|
||
A WD test file is generated which links all of the necessary components: | ||
|
||
* Generated JS test file (e.g. `url-test.js`) | ||
* The test config file (e.g. `url-test-config.js`) | ||
* Test harness (`harness.js`) | ||
* Test files provided by WPT (e.g. `url/urlsearchparams-sort.any.js`) | ||
* JSON resources provided by WPT (e.g. `url/resources/urltestdata.json`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright (c) 2017-2022 Cloudflare, Inc. | ||
// Licensed under the Apache 2.0 license found in the LICENSE file or at: | ||
// https://opensource.org/licenses/Apache-2.0 | ||
|
||
export const config = { | ||
'a-element.js': { ignore: true }, | ||
'a-element-origin.js': { ignore: true }, | ||
'idlharness.any.js': { ignore: true }, | ||
'idlharness-shadowrealm.window.js': { ignore: true }, | ||
'javascript-urls.window.js': { ignore: true }, | ||
'toascii.window.js': { ignore: true }, | ||
'url-setters-a-area.window.js': { ignore: true }, | ||
'percent-encoding.window.js': { ignore: true }, | ||
'historical.any.js': { | ||
expectedFailures: ["Setting URL's href attribute and base URLs"], | ||
}, | ||
'url-constructor.any.js': { | ||
expectedFailures: [ | ||
'Parsing: <http://example.com/\uD800\uD801\uDFFE\uDFFF\uFDD0\uFDCF\uFDEF\uFDF0\uFFFE\uFFFF?\uD800\uD801\uDFFE\uDFFF\uFDD0\uFDCF\uFDEF\uFDF0\uFFFE\uFFFF> without base', | ||
], | ||
}, | ||
'urlencoded-parser.any.js': { | ||
expectedFailures: [ | ||
'request.formData() with input: test', | ||
'response.formData() with input: test', | ||
'request.formData() with input: \uFEFFtest=\uFEFF', | ||
'response.formData() with input: \uFEFFtest=\uFEFF', | ||
'request.formData() with input: %EF%BB%BFtest=%EF%BB%BF', | ||
'response.formData() with input: %EF%BB%BFtest=%EF%BB%BF', | ||
'request.formData() with input: %EF%BF%BF=%EF%BF%BF', | ||
'response.formData() with input: %EF%BF%BF=%EF%BF%BF', | ||
'request.formData() with input: %FE%FF', | ||
'response.formData() with input: %FE%FF', | ||
'request.formData() with input: %FF%FE', | ||
'response.formData() with input: %FF%FE', | ||
'request.formData() with input: †&†=x', | ||
'response.formData() with input: †&†=x', | ||
'request.formData() with input: %C2', | ||
'response.formData() with input: %C2', | ||
'request.formData() with input: %C2x', | ||
'response.formData() with input: %C2x', | ||
'request.formData() with input: _charset_=windows-1252&test=%C2x', | ||
'response.formData() with input: _charset_=windows-1252&test=%C2x', | ||
'request.formData() with input: ', | ||
'response.formData() with input: ', | ||
'request.formData() with input: a', | ||
'response.formData() with input: a', | ||
'request.formData() with input: a=b', | ||
'response.formData() with input: a=b', | ||
'request.formData() with input: a=', | ||
'response.formData() with input: a=', | ||
'request.formData() with input: =b', | ||
'response.formData() with input: =b', | ||
'request.formData() with input: &', | ||
'response.formData() with input: &', | ||
'request.formData() with input: &a', | ||
'response.formData() with input: &a', | ||
'request.formData() with input: a&', | ||
'response.formData() with input: a&', | ||
'request.formData() with input: a&a', | ||
'response.formData() with input: a&a', | ||
'request.formData() with input: a&b&c', | ||
'response.formData() with input: a&b&c', | ||
'request.formData() with input: a=b&c=d', | ||
'response.formData() with input: a=b&c=d', | ||
'request.formData() with input: a=b&c=d&', | ||
'response.formData() with input: a=b&c=d&', | ||
'request.formData() with input: &&&a=b&&&&c=d&', | ||
'response.formData() with input: &&&a=b&&&&c=d&', | ||
'request.formData() with input: a=a&a=b&a=c', | ||
'response.formData() with input: a=a&a=b&a=c', | ||
'request.formData() with input: a==a', | ||
'response.formData() with input: a==a', | ||
'request.formData() with input: a=a+b+c+d', | ||
'response.formData() with input: a=a+b+c+d', | ||
'request.formData() with input: %=a', | ||
'response.formData() with input: %=a', | ||
'request.formData() with input: %a=a', | ||
'response.formData() with input: %a=a', | ||
'request.formData() with input: %a_=a', | ||
'response.formData() with input: %a_=a', | ||
'request.formData() with input: %61=a', | ||
'response.formData() with input: %61=a', | ||
'request.formData() with input: %61+%4d%4D=', | ||
'response.formData() with input: %61+%4d%4D=', | ||
'request.formData() with input: id=0&value=%', | ||
'response.formData() with input: id=0&value=%', | ||
'request.formData() with input: b=%2sf%2a', | ||
'response.formData() with input: b=%2sf%2a', | ||
'request.formData() with input: b=%2%2af%2a', | ||
'response.formData() with input: b=%2%2af%2a', | ||
'request.formData() with input: b=%%2a', | ||
'response.formData() with input: b=%%2a', | ||
], | ||
}, | ||
'urlsearchparams-constructor.any.js': { | ||
expectedFailures: [ | ||
'URLSearchParams constructor, DOMException as argument', | ||
'Construct with 2 unpaired surrogates (no trailing)', | ||
'Construct with 3 unpaired surrogates (no leading)', | ||
'Construct with object with NULL, non-ASCII, and surrogate keys', | ||
], | ||
}, | ||
'urlsearchparams-foreach.any.js': { | ||
skippedTests: ['For-of Check'], | ||
}, | ||
'urlsearchparams-sort.any.js': { | ||
expectedFailures: ['Parse and sort: ffi&🌈', 'URL parse and sort: ffi&🌈'], | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this file typescript and make sure this config is properly typed?