diff options
author | 2022-11-08 17:33:47 -0600 | |
---|---|---|
committer | 2022-11-08 15:33:47 -0800 | |
commit | 9ccc455f8d71e46b8bd967317a2e0e907db27012 (patch) | |
tree | 8f3585457438de35ffc1662b44e0f9a7184233c8 /test/bun.js/bun-spawn-test.js | |
parent | 8b0a3c75cb98f5026de668b3a23d2e42f94e5d1a (diff) | |
download | bun-9ccc455f8d71e46b8bd967317a2e0e907db27012.tar.gz bun-9ccc455f8d71e46b8bd967317a2e0e907db27012.tar.zst bun-9ccc455f8d71e46b8bd967317a2e0e907db27012.zip |
Fix child_process tests (#1471)
* test(child_process): fix broken tests, add our-assert pkg for testing
* test(child_process): replace console.log with debug()
* test(child_process): rename our-assert -> node-test-helpers, use Bun.peek for subproc.exited
Diffstat (limited to 'test/bun.js/bun-spawn-test.js')
-rw-r--r-- | test/bun.js/bun-spawn-test.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/bun.js/bun-spawn-test.js b/test/bun.js/bun-spawn-test.js new file mode 100644 index 000000000..1617a8588 --- /dev/null +++ b/test/bun.js/bun-spawn-test.js @@ -0,0 +1,21 @@ +const EventEmitter = import.meta.require("events"); +class TestClass extends EventEmitter { + #handle = null; + spawn() { + this.#handle = Bun.spawn(["pwd"], { + cwd: "/tmp", + onExit: this.#handleOnExit.bind(this), + }); + } + #handleOnExit(code) { + console.log(code); + this.emit("exit"); + } +} + +const testClass = new TestClass(); +testClass.spawn(); +testClass.on("exit", () => { + console.log("exiting"); + process.exit(0); +}); |