summaryrefslogtreecommitdiff
path: root/tools/wpt/runner.ts
diff options
context:
space:
mode:
authorFilip Skokan <panva.ip@gmail.com>2023-03-02 23:05:17 +0100
committerGitHub <noreply@github.com>2023-03-02 23:05:17 +0100
commit64503fabd81e38c58d44d23ae94f5b87a384b86e (patch)
treec2ef35c55dcccbf6c5efcbd7400ef2d328b72e71 /tools/wpt/runner.ts
parent88c9a999f78916700b35b6a893a5b779a4f86db0 (diff)
test(wpt): implement process timeout, fix expectations update, and more... (#17892)
- relands #17872 - updates the timeouts to be re-configurable just for CI - fixes `./tools/wpt.ts update` - adds option not "ignore" during, applied to wpt epoch runs only
Diffstat (limited to 'tools/wpt/runner.ts')
-rw-r--r--tools/wpt/runner.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts
index a3c22006a..7e15216be 100644
--- a/tools/wpt/runner.ts
+++ b/tools/wpt/runner.ts
@@ -75,13 +75,23 @@ export async function runSingleTest(
_options: ManifestTestOptions,
reporter: (result: TestCaseResult) => void,
inspectBrk: boolean,
+ timeouts: { long: number; default: number },
): Promise<TestResult> {
+ const timeout = _options.timeout === "long"
+ ? timeouts.long
+ : timeouts.default;
+ const filename = url.pathname.substring(
+ url.pathname.lastIndexOf("/") + 1,
+ url.pathname.indexOf("."),
+ );
+ const { title } = Object.fromEntries(_options.script_metadata || []);
const bundle = await generateBundle(url);
const tempFile = await Deno.makeTempFile({
prefix: "wpt-bundle-",
suffix: ".js",
});
+ let interval;
try {
await Deno.writeTextFile(tempFile, bundle);
@@ -107,6 +117,7 @@ export async function runSingleTest(
"[]",
);
+ const start = performance.now();
const proc = new Deno.Command(denoBinary(), {
args,
env: {
@@ -124,10 +135,19 @@ export async function runSingleTest(
const lines = proc.stderr.pipeThrough(new TextDecoderStream()).pipeThrough(
new TextLineStream(),
);
+ interval = setInterval(() => {
+ const passedTime = performance.now() - start;
+ if (passedTime > timeout) {
+ proc.kill("SIGINT");
+ }
+ }, 1000);
for await (const line of lines) {
if (line.startsWith("{")) {
const data = JSON.parse(line);
const result = { ...data, passed: data.status == 0 };
+ if (/^Untitled( \d+)?$/.test(result.name)) {
+ result.name = `${title || filename}${result.name.slice(8)}`;
+ }
cases.push(result);
reporter(result);
} else if (line.startsWith("#$#$#{")) {
@@ -149,6 +169,7 @@ export async function runSingleTest(
stderr,
};
} finally {
+ clearInterval(interval);
await Deno.remove(tempFile);
}
}