Skip to content

Commit

Permalink
test(examples): fixed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Sep 20, 2023
1 parent 3c7f7bf commit 9032f3a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TaskExecutor } from "@golem-sdk/golem-js";
const executor = await TaskExecutor.create({
package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4",
yagnaOptions: { apiKey: "try_golem" },
isSubprocess: true,
});

// there is a mistake and instead of 'node -v' we call 'node -w'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TaskExecutor } from "@golem-sdk/golem-js";
const executor = await TaskExecutor.create({
package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4",
yagnaOptions: { apiKey: "try_golem" },
isSubprocess: true,
});

const result = await executor.run(async (ctx) => await ctx.run("node -v"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello World");
9 changes: 4 additions & 5 deletions tests/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18
const timeoutId = setTimeout(() => {
error = `Test timeout was reached after ${timeout} seconds.`;
spawnedExample.kill();
// for some reason the process doesn't exit after kill, it does so after I type enter
spawnedExample.stdin.write("\n");
spawnedExample.stdin.end();
}, timeout * 1000);
return new Promise((res, rej) => {
spawnedExample.stdout?.on("data", (data: string) => {
console.log(data.trim());
if (criticalLogsRegExp.some((regexp) => data.match(regexp))) {
error = `A critical error occurred during the test.`;
spawnedExample.kill();
spawnedExample.stdin.write("\n");
spawnedExample.stdin.end();
}
// for some reason, sometimes the process doesn't exit after Executor shut down
if (data.indexOf("Task Executor has shut down") !== -1) {
spawnedExample.kill("SIGKILL");
}
});
spawnedExample.on("close", (code) => {
Expand Down

0 comments on commit 9032f3a

Please sign in to comment.