diff options
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/server/servers.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/tests/utils/server/servers.ts b/server/tests/utils/server/servers.ts index fbfc83ca1..3c946db27 100644 --- a/server/tests/utils/server/servers.ts +++ b/server/tests/utils/server/servers.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | import { ChildProcess, exec, fork } from 'child_process' | 1 | import { ChildProcess, exec, fork } from 'child_process' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { root, wait } from '../miscs/miscs' | ||
4 | import { readFile } from 'fs-extra' | ||
3 | 5 | ||
4 | interface ServerInfo { | 6 | interface ServerInfo { |
5 | app: ChildProcess, | 7 | app: ChildProcess, |
@@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) { | |||
157 | } | 159 | } |
158 | } | 160 | } |
159 | 161 | ||
162 | async function waitUntilLog (server: ServerInfo, str: string, count = 1) { | ||
163 | const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') | ||
164 | |||
165 | while (true) { | ||
166 | const buf = await readFile(logfile) | ||
167 | |||
168 | const matches = buf.toString().match(new RegExp(str, 'g')) | ||
169 | if (matches && matches.length === count) return | ||
170 | |||
171 | await wait(1000) | ||
172 | } | ||
173 | } | ||
174 | |||
160 | // --------------------------------------------------------------------------- | 175 | // --------------------------------------------------------------------------- |
161 | 176 | ||
162 | export { | 177 | export { |
@@ -165,5 +180,6 @@ export { | |||
165 | flushTests, | 180 | flushTests, |
166 | runServer, | 181 | runServer, |
167 | killallServers, | 182 | killallServers, |
168 | reRunServer | 183 | reRunServer, |
184 | waitUntilLog | ||
169 | } | 185 | } |