diff options
author | 2023-07-11 12:48:46 -0700 | |
---|---|---|
committer | 2023-07-11 12:48:46 -0700 | |
commit | 5c8726d602fe73e49d027194fef65b9432872c8b (patch) | |
tree | f0ee8944aed349aee715820053fae4ca4aa16688 /test/js/node/process/process.test.js | |
parent | ae7bc37e94185726196a9cf77850379390904d4a (diff) | |
download | bun-5c8726d602fe73e49d027194fef65b9432872c8b.tar.gz bun-5c8726d602fe73e49d027194fef65b9432872c8b.tar.zst bun-5c8726d602fe73e49d027194fef65b9432872c8b.zip |
process signal events (#3569)
* signal events
* simple tests
* ignore SIGSTOP
* better tests
* use `EventEmitter`
* use `Bun__getDefaultGlobal`
* progress
* don't use 'Bun__getDefaultGlobal`
* fix tests
* remove signals from map
* update tests
* don't overwrite event emitter methods
* avoid two lookups
* use `std::once`
* releaseEarly()
* Remove signal handler after use
* Update call-raise.js
* Create process-signal-handler.fixture.js
* Don't register duplicates
* Add missing lock
* another test
* update test
* revert some changes
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/js/node/process/process.test.js')
-rw-r--r-- | test/js/node/process/process.test.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index e038383de..51825b2b4 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,6 +1,6 @@ -import { resolveSync, spawnSync, which } from "bun"; +import { spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; -import { existsSync, readFileSync, realpathSync } from "fs"; +import { existsSync, readFileSync } from "fs"; import { bunEnv, bunExe } from "harness"; import { basename, join, resolve } from "path"; @@ -381,6 +381,28 @@ it("process.getuid", () => { expect(typeof process.getuid()).toBe("number"); }); +describe("signal", () => { + const fixture = join(import.meta.dir, "./process-signal-handler.fixture.js"); + it("simple case works", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR1"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); + it("process.emit will call signal events", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR2"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); +}); + const undefinedStubs = [ "_debugEnd", "_debugProcess", |