diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2021-06-05 14:54:07 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-05 14:54:07 +0900 |
| commit | 5d66bb879464adb2f23d764a3602f967748069d0 (patch) | |
| tree | 3796b93512a5e4bffd6c79ce32471fe6b44cfe01 /test/utils.ts | |
| parent | Add missing migrations (#7552) (diff) | |
| download | sharkey-5d66bb879464adb2f23d764a3602f967748069d0.tar.gz sharkey-5d66bb879464adb2f23d764a3602f967748069d0.tar.bz2 sharkey-5d66bb879464adb2f23d764a3602f967748069d0.zip | |
ランダムにテストがコケるのを修正 (#7553)
* Test shutdown
* Revert "Test shutdown"
This reverts commit 85182e7dd196cdd9ecb46cfb50adaabd04c5ba60.
* Skip beforeShutdown in test
* Wait shutdown in test
* Revert "Skip beforeShutdown in test"
This reverts commit 79c33ab53615e8fa4820d2abfc2494cba55c441c.
* Revert "Revert "Skip beforeShutdown in test""
This reverts commit 3423133a137c79b64f3ff6ef9dbe433a441a47b0.
Diffstat (limited to 'test/utils.ts')
| -rw-r--r-- | test/utils.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/utils.ts b/test/utils.ts index 193017e265..e4c96d0e15 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -5,6 +5,7 @@ const FormData = require('form-data'); import * as childProcess from 'child_process'; import * as http from 'http'; import loadConfig from '../src/config/load'; +import { SIGKILL } from 'constants'; export const port = loadConfig().port; @@ -145,3 +146,19 @@ export function launchServer(callbackSpawnedProcess: (p: childProcess.ChildProce }); }; } + +export function shutdownServer(p: childProcess.ChildProcess, timeout = 20 * 1000) { + return new Promise((res, rej) => { + const t = setTimeout(() => { + p.kill(SIGKILL); + res('force exit'); + }, timeout); + + p.once('exit', () => { + clearTimeout(t); + res('exited'); + }); + + p.kill(); + }); +} |