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

Run idlharness tests on reference implementation #1046

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference-implementation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"nyc": "^15.0.1",
"opener": "^1.5.1",
"webidl2js": "^16.2.0",
"wpt-runner": "^3.0.1"
"wpt-runner": "^3.1.0"
},
"nyc": {
"include": [
Expand Down
22 changes: 16 additions & 6 deletions reference-implementation/run-web-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
/* eslint-disable no-console */
'use strict';
const path = require('path');
const fs = require('fs');
const { promisify } = require('util');
const browserify = require('browserify');
const wptRunner = require('wpt-runner');
const minimatch = require('minimatch');
const readFileAsync = promisify(fs.readFile);

// wpt-runner does not yet support unhandled rejection tracking a la
// https://github.com/w3c/testharness.js/commit/7716e2581a86dfd9405a9c00547a7504f0c7fe94
Expand All @@ -27,7 +29,8 @@ main().catch(e => {

async function main() {
const entryPath = path.resolve(__dirname, 'lib/index.js');
const testsPath = path.resolve(__dirname, 'web-platform-tests/streams');
const wptPath = path.resolve(__dirname, 'web-platform-tests');
const testsPath = path.resolve(wptPath, 'streams');

const filterGlobs = process.argv.length >= 3 ? process.argv.slice(2) : ['**/*.html'];
const workerTestPattern = /\.(?:dedicated|shared|service)worker(?:\.https)?\.html$/;
Expand All @@ -38,6 +41,18 @@ async function main() {
rootURL: 'streams/',
setup(window) {
window.queueMicrotask = queueMicrotask;
window.fetch = async function (url) {
const filePath = path.join(wptPath, url);
if (!filePath.startsWith(wptPath)) {
throw new TypeError('Invalid URL');
}
return {
ok: true,
async text() {
return await readFileAsync(filePath, { encoding: 'utf8' });
}
};
};
window.eval(bundledJS);
},
filter(testPath) {
Expand All @@ -46,11 +61,6 @@ async function main() {
return false;
}

// Ignore for now: wpt-runner doesn't handle the cross-folder dependencies well.
if (testPath === 'idlharness.any.html') {
return false;
}

return filterGlobs.some(glob => minimatch(testPath, glob));
}
});
Expand Down
2 changes: 1 addition & 1 deletion reference-implementation/web-platform-tests