Skip to content

Commit

Permalink
Meta: run idlharness tests on reference implementation
Browse files Browse the repository at this point in the history
Fixes #1044.
  • Loading branch information
MattiasBuelens authored Jun 23, 2020
1 parent c20f174 commit 2b51f36
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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

0 comments on commit 2b51f36

Please sign in to comment.