aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-17 17:30:29 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-17 17:30:29 -0800
commit44cdb1ec8ee0d375d51d672666bc490455b7bed6 (patch)
tree387394dc1962c387307b662cafef6607ec633c29
parente542d9b4ed144adbb9dc16db2e29a04556535724 (diff)
downloadbun-44cdb1ec8ee0d375d51d672666bc490455b7bed6.tar.gz
bun-44cdb1ec8ee0d375d51d672666bc490455b7bed6.tar.zst
bun-44cdb1ec8ee0d375d51d672666bc490455b7bed6.zip
Fix a couple flaky tests
-rw-r--r--test/bun.js/process-args.test.js3
-rw-r--r--test/bun.js/spawn-streaming-stdin.test.ts7
-rw-r--r--test/bun.js/spawn-streaming-stdout-repro.js4
-rw-r--r--test/bun.js/spawn-streaming-stdout.test.ts15
-rw-r--r--test/bun.js/spawn.test.ts1
5 files changed, 17 insertions, 13 deletions
diff --git a/test/bun.js/process-args.test.js b/test/bun.js/process-args.test.js
index 96017266b..a2c79616f 100644
--- a/test/bun.js/process-args.test.js
+++ b/test/bun.js/process-args.test.js
@@ -1,10 +1,11 @@
import { spawn } from "bun";
import { test, expect } from "bun:test";
+import { bunExe } from "./bunExe";
test("args exclude run", async () => {
const arg0 = process.argv[0];
const arg1 = import.meta.dir + "/print-process-args.js";
- const exe = process.versions.bun.includes("debug") ? "bun-debug" : "bun";
+ const exe = bunExe();
const { stdout: s1 } = spawn([exe, "print-process-args.js"], {
cwd: import.meta.dir,
env: { BUN_DEBUG_QUIET_LOGS: "1" },
diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/bun.js/spawn-streaming-stdin.test.ts
index 74bf3dbc9..02067b719 100644
--- a/test/bun.js/spawn-streaming-stdin.test.ts
+++ b/test/bun.js/spawn-streaming-stdin.test.ts
@@ -3,6 +3,7 @@ import { spawn } from "bun";
import { bunExe } from "./bunExe";
import { gcTick } from "gc";
import { closeSync, openSync } from "fs";
+import { bunEnv } from "./bunEnv";
const N = 100;
test("spawn can write to stdin multiple chunks", async () => {
@@ -11,13 +12,11 @@ test("spawn can write to stdin multiple chunks", async () => {
var exited;
await (async function () {
const proc = spawn({
- cmd: ["bun-debug", import.meta.dir + "/stdin-repro.js"],
+ cmd: [bunExe(), import.meta.dir + "/stdin-repro.js"],
stdout: "pipe",
stdin: "pipe",
stderr: Bun.file("/tmp/out.log"),
- env: {
- BUN_DEBUG_QUIET_LOGS: 1,
- },
+ env: bunEnv,
});
exited = proc.exited;
var counter = 0;
diff --git a/test/bun.js/spawn-streaming-stdout-repro.js b/test/bun.js/spawn-streaming-stdout-repro.js
index 7279574bf..3976ff095 100644
--- a/test/bun.js/spawn-streaming-stdout-repro.js
+++ b/test/bun.js/spawn-streaming-stdout-repro.js
@@ -1,3 +1,5 @@
+var writer = Bun.stdout.writer();
setInterval(() => {
- console.log("Wrote to stdout");
+ writer.write("Wrote to stdout\n");
+ writer.flush();
}, 20);
diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/bun.js/spawn-streaming-stdout.test.ts
index fac696087..bda1031ad 100644
--- a/test/bun.js/spawn-streaming-stdout.test.ts
+++ b/test/bun.js/spawn-streaming-stdout.test.ts
@@ -3,6 +3,7 @@ import { spawn } from "bun";
import { bunExe } from "./bunExe";
import { gcTick } from "gc";
import { closeSync, openSync } from "fs";
+import { bunEnv } from "./bunEnv";
test("spawn can read from stdout multiple chunks", async () => {
gcTick(true);
@@ -14,19 +15,17 @@ test("spawn can read from stdout multiple chunks", async () => {
var exited;
const proc = spawn({
cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"],
+ stdin: "ignore",
stdout: "pipe",
stderr: "ignore",
- env: {
- BUN_DEBUG_QUIET_LOGS: 1,
- },
+ env: bunEnv,
});
- exited = proc.exited;
+ var chunks = [];
let counter = 0;
try {
for await (var chunk of proc.stdout) {
- expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n");
+ chunks.push(chunk);
counter++;
-
if (counter > 3) break;
}
} catch (e) {
@@ -34,7 +33,9 @@ test("spawn can read from stdout multiple chunks", async () => {
throw e;
}
expect(counter).toBe(4);
- await exited;
+ // TODO: fix bug with returning SIGHUP instead of exit code 1
+ proc.kill();
+ expect(Buffer.concat(chunks).toString()).toBe("Wrote to stdout\n".repeat(4));
})();
const newMaxFD = openSync("/dev/null", "w");
diff --git a/test/bun.js/spawn.test.ts b/test/bun.js/spawn.test.ts
index 84b0071ea..def0330ee 100644
--- a/test/bun.js/spawn.test.ts
+++ b/test/bun.js/spawn.test.ts
@@ -2,6 +2,7 @@ import { ArrayBufferSink, readableStreamToText, spawn, spawnSync, write } from "
import { describe, expect, it } from "bun:test";
import { gcTick as _gcTick } from "./gc";
import { rmdirSync, unlinkSync, rmSync, writeFileSync } from "node:fs";
+import { bunEnv } from "./bunEnv";
for (let [gcTick, label] of [
[_gcTick, "gcTick"],