Skip to content
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

Support .any.js and .window.js tests #12

Merged
merged 5 commits into from
Nov 21, 2018
Merged

Conversation

MattiasBuelens
Copy link
Contributor

This adds support for running tests with auto-generated test boilerplate, i.e. .any.js and .window.js tests. (Worker tests are ignored since jsdom doesn't support workers yet.)

I've tried to keep the JavaScript implementation as close as possible to the original Python implementation from web-platform-tests. This should (hopefully) make maintaining our implementation a bit easier, in the (rare) case the test format changes in the future.

I have a branch ready which ports the streams tests to the new format. The new test runner executes all tests, and they all pass on the reference implementation! 🎉 After the streams reference implementation is updated to use this new runner, I will submit a PR to web-platform-tests with this branch to migrate the streams tests.

Fixes #11

@MattiasBuelens
Copy link
Contributor Author

If you want to give the updated streams tests a spin for yourself in your local copy of whatwg/streams:

  1. Install the updated runner in reference-implementation/. Personally, I first run npm pack in the runner and then npm install the resulting .tgz. If there's an easier way, feel free to let me know. 😛
  2. Point the reference-implementation/web-platform-tests submodule to the head of my branch.
  3. Run npm test.

Copy link
Owner

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gosh, this is a lot more code than I was anticipating. But, I suppose this is the right way to do things to support all the related features, and do things right going forward. Nice work.

Only one nit, which is to use the correct URL parser package (in all places).

// https://github.com/web-platform-tests/wpt/blob/master/tools/wptserve/wptserve/handlers.py

const path = require("path");
const { parse: parseUrl } = require("url");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the modern WHATWG URL parser, so const { URL } = require("url")? That may also do decoding for you, not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that.

This would require Node 7 or higher, perhaps we should signal the minimum Node version somewhere, e.g. in engines.node of package.json?

I noticed that there's a .travis.yml file in the project that targets Node 4, but there aren't any tests to run on Travis. 🤷‍♂️

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, oh dear. Yeah, let's bump to Node 7 min version, and I'll release this as a new major.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the WHATWG URL parser can't handle relative URLs without passing an absolute base URL. I'll need to check what base URL to use for every parse. I'll look into it.

@@ -25,6 +25,9 @@
"prepare": "npm run copy-testharness",
"copy-testharness": "copyfiles -u 2 wpt/resources/testharness.js testharness/"
},
"engines": {
"node": ">= 8"
Copy link
Contributor Author

@MattiasBuelens MattiasBuelens Nov 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with Node 8 instead of Node 7, since Node 7 is already end-of-life. Plus, Node 8 supports async/await if we later on want to use that. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support .any.js tests
2 participants