Skip to content

Commit

Permalink
Roll web platform tests
Browse files Browse the repository at this point in the history
Includes:

* Some updates to package.json's update-wpt script.
* Fixes to wpt-config.json and tuwpt-config.json to match upstream changes.
* Changed to-upstream/html/webappapis/timers/settimeout-setinterval-handles.html to be less strict, because harness changes have likely caused setTimeout/setInterval to be called somewhere outside the test.
* Improvements to wpt-server.js, to avoid infinite server startup attempts and otherwise clean up the code.

Co-authored-by: Domenic Denicola <d@domenic.me>
  • Loading branch information
asamuzaK and domenic committed Dec 23, 2023
1 parent 0656631 commit 63265a9
Show file tree
Hide file tree
Showing 11 changed files with 96,418 additions and 30,427 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"lint": "eslint . --cache --ext .js,.html",
"init-wpt": "git submodule update --init --recursive",
"reset-wpt": "rm -rf ./test/web-platform-tests/tests && npm run init-wpt",
"update-wpt": "git submodule update --recursive --remote && cd test/web-platform-tests/tests && python3 wpt.py manifest --path ../wpt-manifest.json",
"update-wpt": "git submodule update --init --recursive --remote && cd test/web-platform-tests/tests && python wpt.py manifest --path ../wpt-manifest.json",
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS.txt",
"benchmark": "node ./benchmark/runner",
"convert-idl": "node ./scripts/webidl/convert.js",
Expand Down
3 changes: 2 additions & 1 deletion test/web-platform-tests/run-tuwpts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { describe, before, after } = require("mocha-sugar-free");
const { spawnSync } = require("child_process");
const { readManifest, getPossibleTestFilePaths } = require("./wpt-manifest-utils.js");
const wptServer = require("./wpt-server.js");
const { killSubprocess } = require("./utils.js");

const wptPath = path.resolve(__dirname, "tests");
const testsPath = path.resolve(__dirname, "to-upstream");
Expand All @@ -27,7 +28,7 @@ before({ timeout: 30_000 }, async () => {
});

after(() => {
wptServer.kill(serverProcess);
killSubprocess(serverProcess);
});

describe("Local tests in web-platform-test format (to-upstream)", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/web-platform-tests/run-wpts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Minimatch } = require("minimatch");
const { describe, specify, before, after } = require("mocha-sugar-free");
const { readManifest, getPossibleTestFilePaths } = require("./wpt-manifest-utils.js");
const wptServer = require("./wpt-server.js");
const { resolveReason } = require("./utils.js");
const { resolveReason, killSubprocess } = require("./utils.js");

const validInnerReasons = new Set([
"fail",
Expand Down Expand Up @@ -46,7 +46,7 @@ before({ timeout: 30_000 }, async () => {
});

after(() => {
wptServer.kill(serverProcess);
killSubprocess(serverProcess);
});

describe("web-platform-tests", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/web-platform-tests/tests
Submodule tests updated 14506 files
139 changes: 109 additions & 30 deletions test/web-platform-tests/to-run.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
t.done();
}, 50);

assert_equals(d, c + 1); // since we created the interval after the handle c
assert_true(d >= c + 1); // since we created the interval after the handle c
}, 50);
assert_equals(b, a + 1);

Expand Down
4 changes: 3 additions & 1 deletion test/web-platform-tests/tuwpt-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"wss": [10444]
},
"check_subdomains": true,
"log_level": "info",
"logging": {
"level": "info"
},
"bind_address": true,
"ssl": {
"type": "pregenerated",
Expand Down
36 changes: 36 additions & 0 deletions test/web-platform-tests/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"use strict";
const childProcess = require("child_process");
const http = require("http");
const https = require("https");
const os = require("os");
const { Canvas } = require("../../lib/jsdom/utils.js");

const hasCanvas = Boolean(Canvas);
Expand All @@ -25,3 +29,35 @@ exports.resolveReason = reason => {

return "run";
};

exports.killSubprocess = subprocess => {
if (os.platform() === "win32") {
// subprocess.kill() doesn't seem to be able to kill descendant processes on Windows,
// at least with whatever's going on inside the web-platform-tests Python.
// Use this technique instead.
const { pid } = subprocess;
childProcess.spawnSync("taskkill", ["/F", "/T", "/PID", pid], { detached: true, windowsHide: true });
} else {
// SIGINT is necessary so that the Python script can clean up its subprocesses.
subprocess.kill("SIGINT");
}
};

// We need rejectUnauthorized support so we can't use built-in fetch(), sadly.
exports.doHeadRequestWithNoCertChecking = url => {
const agent = url.startsWith("https") ? new https.Agent({ rejectUnauthorized: false }) : null;
const { request } = url.startsWith("https") ? https : http;

return new Promise((resolve, reject) => {
const req = request(url, { method: "HEAD", agent }, res => {
if (res.statusCode < 200 || res.statusCode > 299) {
reject(new Error(`Unexpected status ${res.statusCode}`));
} else {
resolve();
}
});

req.on("error", reject);
req.end();
});
};
4 changes: 3 additions & 1 deletion test/web-platform-tests/wpt-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"wss": [9444]
},
"check_subdomains": true,
"log_level": "info",
"logging": {
"level": "info"
},
"bind_address": true,
"ssl": {
"type": "pregenerated",
Expand Down

0 comments on commit 63265a9

Please sign in to comment.