Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilums authored and github-actions[bot] committed May 1, 2024
1 parent 9fade01 commit 93efe54
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions test/regression/issue/10080.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ import { bunEnv, bunExe, isPosix } from "harness";
import { tmpdir } from "os";
import { join } from "path";

test.if(isPosix)("10080 - ensure blocking stdio is treated as such in FileReader", async () => {
const expected = "foobar\n";
const filename = join(tmpdir(), "bun.test.stream." + Date.now() + ".js");
const contents = "for await (const line of console) {console.log(`foo${line}`)}"
await Bun.write(filename, contents);
const shellCommand = `exec &> >(${bunExe()} ${filename}); echo "bar"; while read -r line; do echo $line; done`;
test.if(isPosix)(
"10080 - ensure blocking stdio is treated as such in FileReader",
async () => {
const expected = "foobar\n";
const filename = join(tmpdir(), "bun.test.stream." + Date.now() + ".js");
const contents = "for await (const line of console) {console.log(`foo${line}`)}";
await Bun.write(filename, contents);
const shellCommand = `exec &> >(${bunExe()} ${filename}); echo "bar"; while read -r line; do echo $line; done`;

const proc = Bun.spawn(["bash", "-c", shellCommand], {
stdin: "inherit",
stdout: "pipe",
stderr: "inherit",
env: bunEnv,
});
const { value }= await proc.stdout.getReader().read();
const output = new TextDecoder().decode(value);
if (output !== expected) {
expect(output).toEqual(expected);
throw new Error("Output didn't match!\n");
}
const proc = Bun.spawn(["bash", "-c", shellCommand], {
stdin: "inherit",
stdout: "pipe",
stderr: "inherit",
env: bunEnv,
});
const { value } = await proc.stdout.getReader().read();
const output = new TextDecoder().decode(value);
if (output !== expected) {
expect(output).toEqual(expected);
throw new Error("Output didn't match!\n");
}

proc.kill(9);
await proc.exited;
expect(proc.killed).toBeTrue();
}, 1000);
proc.kill(9);
await proc.exited;
expect(proc.killed).toBeTrue();
},
1000,
);

0 comments on commit 93efe54

Please sign in to comment.