From 51a22d4df47de125f46afac52721510ec6e855b1 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Wed, 20 Sep 2023 15:21:33 +0200 Subject: [PATCH] test(examples): fixed examples --- .../examples/composing-tasks/batch-end.mjs | 2 +- tests/examples/examples.test.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/docs-examples/examples/composing-tasks/batch-end.mjs b/examples/docs-examples/examples/composing-tasks/batch-end.mjs index 8a5a9ebd0..a0caa409e 100644 --- a/examples/docs-examples/examples/composing-tasks/batch-end.mjs +++ b/examples/docs-examples/examples/composing-tasks/batch-end.mjs @@ -9,7 +9,7 @@ import { TaskExecutor } from "@golem-sdk/golem-js"; const result = await executor.run(async (ctx) => { const res = await ctx .beginBatch() - .uploadFile("./worker.mjs", "/golem/input/worker.mjs") + .uploadFile("./worker22222.mjs", "/golem/input/worker.mjs") .run("node /golem/input/worker.mjs > /golem/input/output.txt") .run("cat /golem/input/output.txt") .downloadFile("/golem/input/output.txt", "./output.txt") diff --git a/tests/examples/examples.test.ts b/tests/examples/examples.test.ts index 8a8b65bee..168fd82ed 100644 --- a/tests/examples/examples.test.ts +++ b/tests/examples/examples.test.ts @@ -25,21 +25,19 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18 const cwd = dirname(path); const spawnedExample = spawn(cmd, [file, ...args], { cwd }); spawnedExample.stdout?.setEncoding("utf-8"); - const timeoutId = setTimeout(() => { - spawnedExample.kill("SIGABRT"); - }, timeout * 1000); + const timeoutId = setTimeout(() => spawnedExample.kill("SIGINT"), timeout * 1000); return new Promise((res, rej) => { spawnedExample.stdout?.on("data", (data: string) => { console.log(data.trim()); if (criticalLogsRegExp.some((regexp) => data.match(regexp))) { - spawnedExample.kill("SIGKILL"); + spawnedExample.kill("SIGTERM"); } }); spawnedExample.on("close", (code, signal) => { if (signal === null) return res(true); let errorMsg = ""; - if (signal === "SIGABRT") errorMsg = `Test timeout was reached after ${timeout} seconds.`; - if (signal === "SIGKILL") errorMsg = `A critical error occurred during the test.`; + if (signal === "SIGINT") errorMsg = `Test timeout was reached after ${timeout} seconds.`; + if (signal === "SIGTERM") errorMsg = `A critical error occurred during the test.`; rej(`Test example "${file}" failed. ${errorMsg}`); }); }).finally(() => {