diff options
author | 2023-01-23 15:59:45 -0800 | |
---|---|---|
committer | 2023-01-23 15:59:45 -0800 | |
commit | 79c0b614ee04d06d9565cd52450b0de1f58fa87e (patch) | |
tree | 3bd01e49d3f6ecb3e04bf3ff71552b5c14bf0298 /test/bun.js/child_process-node.test.js | |
parent | f5cda8ff1871571e3a6e655326fcda56e65e0dfb (diff) | |
download | bun-79c0b614ee04d06d9565cd52450b0de1f58fa87e.tar.gz bun-79c0b614ee04d06d9565cd52450b0de1f58fa87e.tar.zst bun-79c0b614ee04d06d9565cd52450b0de1f58fa87e.zip |
fix child process node test hang (#1884)
* fix test hang from skipped tests
* add error target
Diffstat (limited to 'test/bun.js/child_process-node.test.js')
-rw-r--r-- | test/bun.js/child_process-node.test.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/bun.js/child_process-node.test.js b/test/bun.js/child_process-node.test.js index 664fc8f8b..a225172ce 100644 --- a/test/bun.js/child_process-node.test.js +++ b/test/bun.js/child_process-node.test.js @@ -170,7 +170,7 @@ describe("ChildProcess spawn bad stdio", () => { // Monkey patch spawn() to create a child process normally, but destroy the // stdout and stderr streams. This replicates the conditions where the streams // cannot be properly created. - function createChild(options, callback, done) { + function createChild(options, callback, done, target) { var __originalSpawn = ChildProcess.prototype.spawn; ChildProcess.prototype.spawn = function () { const err = __originalSpawn.apply(this, arguments); @@ -182,13 +182,14 @@ describe("ChildProcess spawn bad stdio", () => { }; const { mustCall } = createCallCheckCtx(done); - const cmd = `bun ${__dirname}/spawned-child.js`; + let cmd = `bun ${import.meta.dir}/spawned-child.js`; + if (target) cmd += " " + target; const child = exec(cmd, options, mustCall(callback)); ChildProcess.prototype.spawn = __originalSpawn; return child; } - it.skip("should handle normal execution of child process", (done) => { + it("should handle normal execution of child process", (done) => { createChild( {}, (err, stdout, stderr) => { @@ -200,16 +201,19 @@ describe("ChildProcess spawn bad stdio", () => { ); }); - it.skip("should handle error event of child process", (done) => { - const error = new Error("foo"); + it("should handle error event of child process", (done) => { + const error = new Error( + `Command failed: bun ${import.meta.dir}/spawned-child.js ERROR`, + ); createChild( {}, (err, stdout, stderr) => { - strictEqual(err, error); + strictEqual(err.message, error.message); strictEqual(stdout, ""); strictEqual(stderr, ""); }, done, + "ERROR", ); }); |