1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

test(wpt): implement process timeout (#17872)

```
response-consume-stream.any.js
Blob-stream.any.js
```

These tests just hang whenever they get to use byob mode. This PR adds a
timeout to the spawned process so that the WPTs finish running.

This first broke the daily run due to
7b49c547d4

Also fixes "Untitled" test names in
https://wpt.fyi/results/dom/events/Event-constructors.any.html?label=experimental&label=master&product=deno&product=chrome&aligned&view=subtest
This commit is contained in:
Filip Skokan 2023-02-22 21:45:21 +01:00 committed by GitHub
parent a6ca4d0d61
commit 5fcbdd6228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -1087,8 +1087,8 @@
"EventTarget-constructible.any.html": true, "EventTarget-constructible.any.html": true,
"EventTarget-constructible.any.worker.html": true, "EventTarget-constructible.any.worker.html": true,
"Event-constructors.any.html": [ "Event-constructors.any.html": [
"Untitled 3", "Event constructors 3",
"Untitled 4" "Event constructors 4"
], ],
"Event-constructors.any.worker.html": [ "Event-constructors.any.worker.html": [
"Event constructors 3", "Event constructors 3",

View file

@ -76,12 +76,15 @@ export async function runSingleTest(
reporter: (result: TestCaseResult) => void, reporter: (result: TestCaseResult) => void,
inspectBrk: boolean, inspectBrk: boolean,
): Promise<TestResult> { ): Promise<TestResult> {
const timeout = _options.timeout === "long" ? 60_000 : 20_000;
const { title } = Object.fromEntries(_options.script_metadata || []);
const bundle = await generateBundle(url); const bundle = await generateBundle(url);
const tempFile = await Deno.makeTempFile({ const tempFile = await Deno.makeTempFile({
prefix: "wpt-bundle-", prefix: "wpt-bundle-",
suffix: ".js", suffix: ".js",
}); });
let interval;
try { try {
await Deno.writeTextFile(tempFile, bundle); await Deno.writeTextFile(tempFile, bundle);
@ -107,6 +110,7 @@ export async function runSingleTest(
"[]", "[]",
); );
const start = performance.now();
const proc = new Deno.Command(denoBinary(), { const proc = new Deno.Command(denoBinary(), {
args, args,
env: { env: {
@ -124,10 +128,19 @@ export async function runSingleTest(
const lines = proc.stderr.pipeThrough(new TextDecoderStream()).pipeThrough( const lines = proc.stderr.pipeThrough(new TextDecoderStream()).pipeThrough(
new TextLineStream(), new TextLineStream(),
); );
interval = setInterval(() => {
const passedTime = performance.now() - start;
if (passedTime > timeout) {
proc.kill("SIGINT");
}
}, 1000);
for await (const line of lines) { for await (const line of lines) {
if (line.startsWith("{")) { if (line.startsWith("{")) {
const data = JSON.parse(line); const data = JSON.parse(line);
const result = { ...data, passed: data.status == 0 }; const result = { ...data, passed: data.status == 0 };
if (title && /^Untitled( \d+)?$/.test(result.name)) {
result.name = `${title}${result.name.slice(8)}`;
}
cases.push(result); cases.push(result);
reporter(result); reporter(result);
} else if (line.startsWith("#$#$#{")) { } else if (line.startsWith("#$#$#{")) {
@ -149,6 +162,7 @@ export async function runSingleTest(
stderr, stderr,
}; };
} finally { } finally {
clearInterval(interval);
await Deno.remove(tempFile); await Deno.remove(tempFile);
} }
} }