import { spawn, spawnSync } from "bun"; import { describe, expect, it, test } from "bun:test"; import { bunExe } from "bunExe"; import { isatty } from "tty"; test("process.stdin", () => { expect(process.stdin).toBeDefined(); expect(process.stdout.isTTY).toBe(isatty(0)); expect(process.stdin.on("close", function () {})).toBe(process.stdin); expect(process.stdin.once("end", function () {})).toBe(process.stdin); }); test("process.stdin - read", async () => { const { stdin, stdout } = spawn({ cmd: [bunExe(), import.meta.dir + "/process-stdin-echo.js"], stdout: "pipe", stdin: "pipe", stderr: null, env: { ...process.env, BUN_DEBUG_QUIET_LOGS: "1", }, }); expect(stdin).toBeDefined(); expect(stdout).toBeDefined(); var lines = ["Get Emoji", "β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste", "πŸ‘Œ", ""]; for (let i = 0; i < lines.length; i++) { const line = lines[i]; setTimeout(() => { if (line) { stdin?.write(line + "\n"); stdin?.flush(); } else { stdin?.end(); } }, i * 200); } var text = await new Response(stdout).text(); expect(text).toBe(lines.join("\n") + "ENDED"); }); test("process.stdin - resume", async () => { const { stdin, stdout } = spawn({ cmd: [bunExe(), import.meta.dir + "/process-stdin-echo.js", "resume"], stdout: "pipe", stdin: "pipe", stderr: null, env: { ...process.env, BUN_DEBUG_QUIET_LOGS: "1", }, }); expect(stdin).toBeDefined(); expect(stdout).toBeDefined(); var lines = ["Get Emoji", "β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste", "πŸ‘Œ", ""]; for (let i = 0; i < lines.length; i++) { const line = lines[i]; setTimeout(() => { if (line) { stdin?.write(line + "\n"); stdin?.flush(); } else { stdin?.end(); } }, i * 200); } var text = await new Response(stdout).text(); expect(text).toBe("RESUMED" + lines.join("\n") + "ENDED"); }); test("process.stdout", () => { expect(process.stdout).toBeDefined(); expect(process.stdout.isTTY).toBe(isatty(1)); }); test("process.stderr", () => { expect(process.stderr).toBeDefined(); expect(process.stderr.isTTY).toBe(isatty(2)); }); test("process.stdout - write", () => { const { stdout } = spawnSync({ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance.js"], stdout: "pipe", stdin: null, stderr: null, env: { ...process.env, BUN_DEBUG_QUIET_LOGS: "1", }, }); expect(stdout?.toString()).toBe(`hello worldhello again|πŸ˜‹ Get Emoji β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste πŸ‘Œ`); }); test("process.stdout - write a lot (string)", () => { const { stdout } = spawnSync({ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance-a-lot.js"], stdout: "pipe", stdin: null, stderr: null, env: { ...process.env, BUN_DEBUG_QUIET_LOGS: "1", TEST_STDIO_STRING: "1", }, }); expect(stdout?.toString()).toBe( `hello worldhello again|πŸ˜‹ Get Emoji β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste πŸ‘Œ`.repeat(9999), ); }); test("process.stdout - write a lot (bytes)", () => { const { stdout } = spawnSync({ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance-a-lot.js"], stdout: "pipe", stdin: null, stderr: null, env: { ...process.env, BUN_DEBUG_QUIET_LOGS: "1", }, }); expect(stdout?.toString()).toBe( `hello worldhello again|πŸ˜‹ Get Emoji β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste πŸ‘Œ`.repeat(9999), ); }); test'>examples/container-with-vitest Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/scripts/cmd (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2022-04-26[ci] formatGravatar matthewp 1-1/+1
2022-04-26fix(vercel): `trailingSlash` fix for non-html pages (#3185)Gravatar Juan MartΓ­n Seery 2-29/+42
* fix(vercel): `trailingSlash` fix for non-html pages * Changeset
2022-04-26Prevent watcher from running during the build (#3207)Gravatar Matthew Phillips 2-0/+9
* Prevent watcher from running during the build * Adds a changeset
2022-04-26Fix lockfile (#3210)Gravatar Juan MartΓ­n Seery 1-6/+0
2022-04-26Add missing is:raw in AstroBuiltinAttributes (#3209)Gravatar Erika 2-0/+6
2022-04-26Feat: support `astro add` without npm installing (#3183)Gravatar Ben Holmes 6-30/+49
* deps: update to latest proload * feat: avoid parsing config on resolveConfigUrl * chore: changeset * fix: bump proload * fix: bump proload * fix: bump proload * fix: bump proload * fix: bump proload Co-authored-by: Nate Moore <nate@skypack.dev>
2022-04-26Add Astro attributes to svg elements (#3205)Gravatar Erika 2-1/+9
2022-04-26[ci] formatGravatar bholmesdev 2-9/+9
2022-04-26Feat: `create astro` add install step (#3190)Gravatar Ben Holmes 7-162/+299
* feat: add instlal step with pkg manager detection * feat: add package emoji for style points * feat: update next steps to match pkg manager * refactor: extract some create-astro test utils * refactor: extract promp msgs to utils * chore: add install step tests * chore: changeset * fix: remove directory test skip * fix: unset env variables after install step test * deps: add execa to create-astro * refactor: use execa for install step * chore: remove old comment * fix: rework install step test for node 14? * chore: remove "politely stolen" footnote * temp: show stdout dialog * feat: remove debugging logs, add dryrun flag for testing * chore: more stray logs * fix: remove rmdir
2022-04-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-25fix(markdown): file.url fixes (#3198)Gravatar Juan MartΓ­n Seery 11-10/+149
* fix(markdown): file.url fixes * Added tests * Changed the default of `base` from `./` to `/` * Make the url work with subpath * Changeset * Forgot to change this comparison
2022-04-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-24add vite to licenseGravatar Fred K. Schott 2-24/+29
2022-04-24feat(markdown): Improved types (#3191)Gravatar Juan MartΓ­n Seery 3-6/+47
* feat(markdown): Improved types * More MarkdownMetadata
2022-04-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-23[ci] collect statsGravatar FredKSchott 1-0/+1