aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-04-06 16:59:06 -0400
committerGravatar GitHub <noreply@github.com> 2023-04-06 13:59:06 -0700
commitf788519263b5713cd5655a6e3bcf3e3f9b1aea02 (patch)
tree748c890359263f9a7603f0f06d4d307907db939f /test
parent8a73c2a453fc3a569073f6f1f584369d657686f5 (diff)
downloadbun-f788519263b5713cd5655a6e3bcf3e3f9b1aea02.tar.gz
bun-f788519263b5713cd5655a6e3bcf3e3f9b1aea02.tar.zst
bun-f788519263b5713cd5655a6e3bcf3e3f9b1aea02.zip
bun-types: infer strict `Subprocess` from `Bun.spawn()` options, part 2 (#2573)
Diffstat (limited to 'test')
-rw-r--r--test/cli/hot/hot.test.ts12
-rw-r--r--test/js/bun/spawn/spawn-streaming-stdin.test.ts2
-rw-r--r--test/js/bun/spawn/spawn-streaming-stdout.test.ts2
-rw-r--r--test/js/bun/spawn/spawn.test.ts8
-rw-r--r--test/js/node/child_process/child_process.test.ts2
-rw-r--r--test/regression/issue/02499.test.ts11
6 files changed, 18 insertions, 19 deletions
diff --git a/test/cli/hot/hot.test.ts b/test/cli/hot/hot.test.ts
index 7888f0308..63cc3b064 100644
--- a/test/cli/hot/hot.test.ts
+++ b/test/cli/hot/hot.test.ts
@@ -19,7 +19,7 @@ it("should hot reload when file is overwritten", async () => {
writeFileSync(root, readFileSync(root, "utf-8"));
}
- for await (const line of runner.stdout!) {
+ for await (const line of runner.stdout) {
var str = new TextDecoder().decode(line);
var any = false;
for (let line of str.split("\n")) {
@@ -66,7 +66,7 @@ it("should recover from errors", async () => {
var errors: string[] = [];
var onError: (...args: any[]) => void;
(async () => {
- for await (let line of runner.stderr!) {
+ for await (let line of runner.stderr) {
var str = new TextDecoder().decode(line);
errors.push(str);
// @ts-ignore
@@ -74,7 +74,7 @@ it("should recover from errors", async () => {
}
})();
- for await (const line of runner.stdout!) {
+ for await (const line of runner.stdout) {
var str = new TextDecoder().decode(line);
var any = false;
for (let line of str.split("\n")) {
@@ -138,7 +138,7 @@ it("should not hot reload when a random file is written", async () => {
if (finished) {
return;
}
- for await (const line of runner.stdout!) {
+ for await (const line of runner.stdout) {
if (finished) {
return;
}
@@ -182,7 +182,7 @@ it("should hot reload when a file is deleted and rewritten", async () => {
writeFileSync(root, contents);
}
- for await (const line of runner.stdout!) {
+ for await (const line of runner.stdout) {
var str = new TextDecoder().decode(line);
var any = false;
for (let line of str.split("\n")) {
@@ -227,7 +227,7 @@ it("should hot reload when a file is renamed() into place", async () => {
await 1;
}
- for await (const line of runner.stdout!) {
+ for await (const line of runner.stdout) {
var str = new TextDecoder().decode(line);
var any = false;
for (let line of str.split("\n")) {
diff --git a/test/js/bun/spawn/spawn-streaming-stdin.test.ts b/test/js/bun/spawn/spawn-streaming-stdin.test.ts
index f69e7d9b6..27efa14ec 100644
--- a/test/js/bun/spawn/spawn-streaming-stdin.test.ts
+++ b/test/js/bun/spawn/spawn-streaming-stdin.test.ts
@@ -22,7 +22,7 @@ test("spawn can write to stdin multiple chunks", async () => {
var chunks: any[] = [];
const prom = (async function () {
try {
- for await (var chunk of proc.stdout!) {
+ for await (var chunk of proc.stdout) {
chunks.push(chunk);
}
} catch (e: any) {
diff --git a/test/js/bun/spawn/spawn-streaming-stdout.test.ts b/test/js/bun/spawn/spawn-streaming-stdout.test.ts
index 54c1451f0..558a70371 100644
--- a/test/js/bun/spawn/spawn-streaming-stdout.test.ts
+++ b/test/js/bun/spawn/spawn-streaming-stdout.test.ts
@@ -21,7 +21,7 @@ test("spawn can read from stdout multiple chunks", async () => {
var chunks = [];
let counter = 0;
try {
- for await (var chunk of proc.stdout!) {
+ for await (var chunk of proc.stdout) {
chunks.push(chunk);
counter++;
if (counter > 3) break;
diff --git a/test/js/bun/spawn/spawn.test.ts b/test/js/bun/spawn/spawn.test.ts
index 54b890d51..c43c06d02 100644
--- a/test/js/bun/spawn/spawn.test.ts
+++ b/test/js/bun/spawn/spawn.test.ts
@@ -116,7 +116,7 @@ for (let [gcTick, label] of [
cmd: ["sleep", "0.1"],
});
gcTick();
- for await (const _ of proc.stdout!) {
+ for await (const _ of proc.stdout) {
throw new Error("should not happen");
}
gcTick();
@@ -264,7 +264,7 @@ for (let [gcTick, label] of [
stderr: "inherit",
});
- var stdout = proc.stdout!;
+ var stdout = proc.stdout;
var reader = stdout.getReader();
proc.stdin!.write("hey\n");
await proc.stdin!.end();
@@ -319,7 +319,7 @@ for (let [gcTick, label] of [
describe("should should allow reading stdout", () => {
it("before exit", async () => {
const process = callback();
- const output = await readableStreamToText(process.stdout!);
+ const output = await readableStreamToText(process.stdout);
await process.exited;
const expected = fixture + "\n";
@@ -366,7 +366,7 @@ for (let [gcTick, label] of [
it("after exit", async () => {
const process = callback();
await process.exited;
- const output = await readableStreamToText(process.stdout!);
+ const output = await readableStreamToText(process.stdout);
const expected = fixture + "\n";
expect(output.length).toBe(expected.length);
expect(output).toBe(expected);
diff --git a/test/js/node/child_process/child_process.test.ts b/test/js/node/child_process/child_process.test.ts
index c249c6434..f4e08ac74 100644
--- a/test/js/node/child_process/child_process.test.ts
+++ b/test/js/node/child_process/child_process.test.ts
@@ -327,7 +327,7 @@ describe("Bun.spawn()", () => {
stdout: "pipe",
});
- for await (const chunk of proc.stdout!) {
+ for await (const chunk of proc.stdout) {
const text = new TextDecoder().decode(chunk);
expect(text.trim()).toBe("hello");
}
diff --git a/test/regression/issue/02499.test.ts b/test/regression/issue/02499.test.ts
index da114d95d..0e4666b36 100644
--- a/test/regression/issue/02499.test.ts
+++ b/test/regression/issue/02499.test.ts
@@ -44,17 +44,16 @@ it("onAborted() and onWritable are not called after receiving an empty response
env: bunEnv,
});
- const reader = bunProcess.stdout?.getReader();
+ const reader = bunProcess.stdout.getReader();
let hostname, port;
{
- const chunks = [];
+ const chunks: Buffer[] = [];
var decoder = new TextDecoder();
while (!hostname && !port) {
- // @ts-expect-error TODO
- var { value, done } = await reader?.read();
+ var { value, done } = await reader.read();
if (done) break;
if (chunks.length > 0) {
- chunks.push(value);
+ chunks.push(value!);
}
try {
if (chunks.length > 0) {
@@ -63,7 +62,7 @@ it("onAborted() and onWritable are not called after receiving an empty response
({ hostname, port } = JSON.parse(decoder.decode(value).trim()));
} catch {
- chunks.push(value);
+ chunks.push(value!);
}
}
}