0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-04 01:44:26 -05:00

chore: bump child_process_test timeouts for slow CI (#18689)

This commit is contained in:
David Sherret 2023-04-13 13:30:30 -04:00 committed by Levente Kurusa
parent d5356f6687
commit 2b35ddfc46
No known key found for this signature in database
GPG key ID: 9F72F3C05BA137C4

View file

@ -15,7 +15,7 @@ import * as path from "../../../test_util/std/path/mod.ts";
const { spawn, execFile, execFileSync, ChildProcess } = CP; const { spawn, execFile, execFileSync, ChildProcess } = CP;
function withTimeout<T>(timeoutInMS: number): Deferred<T> { function withTimeout<T>(timeoutInMS = 10_000): Deferred<T> {
const promise = deferred<T>(); const promise = deferred<T>();
const timer = setTimeout(() => { const timer = setTimeout(() => {
promise.reject("Timeout"); promise.reject("Timeout");
@ -28,7 +28,7 @@ function withTimeout<T>(timeoutInMS: number): Deferred<T> {
// TODO(uki00a): Once Node.js's `parallel/test-child-process-spawn-error.js` works, this test case should be removed. // TODO(uki00a): Once Node.js's `parallel/test-child-process-spawn-error.js` works, this test case should be removed.
Deno.test("[node/child_process spawn] The 'error' event is emitted when no binary is found", async () => { Deno.test("[node/child_process spawn] The 'error' event is emitted when no binary is found", async () => {
const promise = withTimeout(1000); const promise = withTimeout();
const childProcess = spawn("no-such-cmd"); const childProcess = spawn("no-such-cmd");
childProcess.on("error", (_err: Error) => { childProcess.on("error", (_err: Error) => {
// TODO(@bartlomieju) Assert an error message. // TODO(@bartlomieju) Assert an error message.
@ -38,7 +38,7 @@ Deno.test("[node/child_process spawn] The 'error' event is emitted when no binar
}); });
Deno.test("[node/child_process spawn] The 'exit' event is emitted with an exit code after the child process ends", async () => { Deno.test("[node/child_process spawn] The 'exit' event is emitted with an exit code after the child process ends", async () => {
const promise = withTimeout(3000); const promise = withTimeout();
const childProcess = spawn(Deno.execPath(), ["--help"], { const childProcess = spawn(Deno.execPath(), ["--help"], {
env: { NO_COLOR: "true" }, env: { NO_COLOR: "true" },
}); });
@ -59,7 +59,7 @@ Deno.test("[node/child_process spawn] The 'exit' event is emitted with an exit c
}); });
Deno.test("[node/child_process disconnect] the method exists", async () => { Deno.test("[node/child_process disconnect] the method exists", async () => {
const promise = withTimeout(1000); const promise = withTimeout();
const childProcess = spawn(Deno.execPath(), ["--help"], { const childProcess = spawn(Deno.execPath(), ["--help"], {
env: { NO_COLOR: "true" }, env: { NO_COLOR: "true" },
}); });
@ -79,7 +79,7 @@ Deno.test("[node/child_process disconnect] the method exists", async () => {
Deno.test({ Deno.test({
name: "[node/child_process spawn] Verify that stdin and stdout work", name: "[node/child_process spawn] Verify that stdin and stdout work",
fn: async () => { fn: async () => {
const promise = withTimeout(3000); const promise = withTimeout();
const childProcess = spawn(Deno.execPath(), ["fmt", "-"], { const childProcess = spawn(Deno.execPath(), ["fmt", "-"], {
env: { NO_COLOR: "true" }, env: { NO_COLOR: "true" },
stdio: ["pipe", "pipe"], stdio: ["pipe", "pipe"],
@ -107,7 +107,7 @@ Deno.test({
Deno.test({ Deno.test({
name: "[node/child_process spawn] stdin and stdout with binary data", name: "[node/child_process spawn] stdin and stdout with binary data",
fn: async () => { fn: async () => {
const promise = withTimeout(10000); const promise = withTimeout();
const p = path.join( const p = path.join(
path.dirname(path.fromFileUrl(import.meta.url)), path.dirname(path.fromFileUrl(import.meta.url)),
"./testdata/binary_stdio.js", "./testdata/binary_stdio.js",
@ -140,7 +140,7 @@ Deno.test({
async function spawnAndGetEnvValue( async function spawnAndGetEnvValue(
inputValue: string | number | boolean, inputValue: string | number | boolean,
): Promise<string> { ): Promise<string> {
const promise = withTimeout<string>(3000); const promise = withTimeout<string>();
const env = spawn( const env = spawn(
`"${Deno.execPath()}" eval -p "Deno.env.toObject().BAZ"`, `"${Deno.execPath()}" eval -p "Deno.env.toObject().BAZ"`,
{ {
@ -191,7 +191,7 @@ Deno.test({
// TODO(uki00a): Remove this case once Node's `parallel/test-child-process-spawn-event.js` works. // TODO(uki00a): Remove this case once Node's `parallel/test-child-process-spawn-event.js` works.
Deno.test("[child_process spawn] 'spawn' event", async () => { Deno.test("[child_process spawn] 'spawn' event", async () => {
const timeout = withTimeout(3000); const timeout = withTimeout();
const subprocess = spawn(Deno.execPath(), ["eval", "console.log('ok')"]); const subprocess = spawn(Deno.execPath(), ["eval", "console.log('ok')"]);
let didSpawn = false; let didSpawn = false;
@ -238,7 +238,7 @@ Deno.test("[child_process spawn] 'spawn' event", async () => {
// TODO(uki00a): Remove this case once Node's `parallel/test-child-process-spawn-shell.js` works. // TODO(uki00a): Remove this case once Node's `parallel/test-child-process-spawn-shell.js` works.
Deno.test("[child_process spawn] Verify that a shell is executed", async () => { Deno.test("[child_process spawn] Verify that a shell is executed", async () => {
const promise = withTimeout(3000); const promise = withTimeout();
const doesNotExist = spawn("does-not-exist", { shell: true }); const doesNotExist = spawn("does-not-exist", { shell: true });
try { try {
assertNotStrictEquals(doesNotExist.spawnfile, "does-not-exist"); assertNotStrictEquals(doesNotExist.spawnfile, "does-not-exist");
@ -269,7 +269,7 @@ Deno.test({
ignore: Deno.build.os === "windows", ignore: Deno.build.os === "windows",
name: "[node/child_process spawn] Verify that passing arguments works", name: "[node/child_process spawn] Verify that passing arguments works",
async fn() { async fn() {
const promise = withTimeout(3000); const promise = withTimeout();
const echo = spawn("echo", ["foo"], { const echo = spawn("echo", ["foo"], {
shell: true, shell: true,
}); });
@ -300,7 +300,7 @@ Deno.test({
ignore: Deno.build.os === "windows", ignore: Deno.build.os === "windows",
name: "[node/child_process spawn] Verity that shell features can be used", name: "[node/child_process spawn] Verity that shell features can be used",
async fn() { async fn() {
const promise = withTimeout(3000); const promise = withTimeout();
const cmd = "echo bar | cat"; const cmd = "echo bar | cat";
const command = spawn(cmd, { const command = spawn(cmd, {
shell: true, shell: true,
@ -331,7 +331,7 @@ Deno.test({
name: name:
"[node/child_process spawn] Verity that environment is properly inherited", "[node/child_process spawn] Verity that environment is properly inherited",
async fn() { async fn() {
const promise = withTimeout(3000); const promise = withTimeout();
const env = spawn( const env = spawn(
`"${Deno.execPath()}" eval -p "Deno.env.toObject().BAZ"`, `"${Deno.execPath()}" eval -p "Deno.env.toObject().BAZ"`,
{ {
@ -496,7 +496,7 @@ Deno.test({
"./testdata/infinite_loop.js", "./testdata/infinite_loop.js",
); );
const childProcess = spawn(Deno.execPath(), ["run", script]); const childProcess = spawn(Deno.execPath(), ["run", script]);
const p = withTimeout(3000); const p = withTimeout();
childProcess.on("exit", () => p.resolve()); childProcess.on("exit", () => p.resolve());
childProcess.kill("SIGKILL"); childProcess.kill("SIGKILL");
await p; await p;