aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/server/servers.ts18
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 @@
1import { ChildProcess, exec, fork } from 'child_process' 1import { ChildProcess, exec, fork } from 'child_process'
2import { join } from 'path' 2import { join } from 'path'
3import { root, wait } from '../miscs/miscs'
4import { readFile } from 'fs-extra'
3 5
4interface ServerInfo { 6interface ServerInfo {
5 app: ChildProcess, 7 app: ChildProcess,
@@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) {
157 } 159 }
158} 160}
159 161
162async 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
162export { 177export {
@@ -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}