From 6a8afee38038b34eb8abc228419d1666fdf7faab Mon Sep 17 00:00:00 2001 From: waiting <1661926154@qq.com> Date: Sun, 3 Mar 2019 19:44:06 +0800 Subject: [PATCH] test: fix ELIFECYCLE --- test/70_user32.test.ts | 9 ++++++--- test/90_loop_callback.test.ts | 2 -- test/helper.ts | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/70_user32.test.ts b/test/70_user32.test.ts index 06d5ddad..c4d9ae1c 100644 --- a/test/70_user32.test.ts +++ b/test/70_user32.test.ts @@ -65,8 +65,6 @@ describe(filename, () => { done() }, () => { - // tslint:disable-next-line:no-unused-expression - typeof enumWindowsProc // avoid gc child.kill() done() }, @@ -107,10 +105,15 @@ function createEnumWinProc(): M.WNDENUMPROC { }, ) + process.on('exit', () => { + // tslint:disable-next-line:no-unused-expression + typeof enumWindowsProc // avoid gc + }) + return enumWindowsProc } function enumWindows(proc: M.WNDENUMPROC, id: number): void { - user32.EnumWindows(proc , id) + user32.EnumWindows(proc, id) } diff --git a/test/90_loop_callback.test.ts b/test/90_loop_callback.test.ts index 642bfff5..b7d459ae 100644 --- a/test/90_loop_callback.test.ts +++ b/test/90_loop_callback.test.ts @@ -67,8 +67,6 @@ describe(filename, () => { const end = new Date().getTime() const delta = end - start console.info(`elp ${delta}ms at ${loops} loops`) - // tslint:disable-next-line:no-unused-expression - typeof wndProc // avoid gc }, ) diff --git a/test/helper.ts b/test/helper.ts index 8139bd8f..6ae6c326 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -41,6 +41,11 @@ export function createWndProc(): M.WNDPROC { }, ) + process.on('exit', () => { + // tslint:disable-next-line:no-unused-expression + WndProc // avoid gc + }) + return WndProc }