From: Chocobozzz Date: Wed, 24 Apr 2019 10:02:04 +0000 (+0200) Subject: Try to fix travis X-Git-Tag: v1.3.0-rc.1~46 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=42e1ec25ece5ef6b7a29d64610e3729578059e52;p=oweals%2Fpeertube.git Try to fix travis --- diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 00d0a7e2b..d2fea65f6 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -6,9 +6,27 @@ import { join } from 'path' import { UserRole, VideoImport, VideoImportState } from '../../../../shared' import { - createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, - makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, flushAndRunServer, ServerInfo, setAccessTokensToServers, - updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser + blockUser, + createUser, + deleteMe, + flushAndRunServer, + getMyUserInformation, + getMyUserVideoRating, + getUsersList, + immutableAssign, + killallServers, + makeGetRequest, + makePostBodyRequest, + makePutBodyRequest, + makeUploadRequest, + registerUser, + removeUser, + ServerInfo, + setAccessTokensToServers, + unblockUser, + updateUser, + uploadVideo, + userLogin } from '../../../../shared/extra-utils' import { checkBadCountPagination, diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index bb14abbfd..dfa4c29b6 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts @@ -4,8 +4,15 @@ import * as chai from 'chai' import 'mocha' import { createUser, - flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers, - uploadVideo, userLogin + flushAndRunServer, + killallServers, + makeDeleteRequest, + makeGetRequest, + makePostBodyRequest, + ServerInfo, + setAccessTokensToServers, + uploadVideo, + userLogin } from '../../../../shared/extra-utils' import { checkBadCountPagination, diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index c921eb74d..c63725d71 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -2,7 +2,7 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' +import { flushAndRunServer, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' import { VideosOverview } from '../../../../shared/models/overviews' diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 480d12330..add738056 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -87,12 +87,14 @@ function randomServer () { return Math.floor(Math.random() * (high - low) + low) } -function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) { +async function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) { const parallel = process.env.MOCHA_PARALLEL === 'true' const internalServerNumber = parallel ? randomServer() : serverNumber const port = 9000 + internalServerNumber + await flushTests(serverNumber) + const server: ServerInfo = { app: null, port, @@ -175,45 +177,41 @@ function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, ar } return new Promise(res => { - flushTests(internalServerNumber) - .then(() => { - - server.app = fork(join(root(), 'dist', 'server.js'), args, options) - server.app.stdout.on('data', function onStdout (data) { - let dontContinue = false - - // Capture things if we want to - for (const key of Object.keys(regexps)) { - const regexp = regexps[ key ] - const matches = data.toString().match(regexp) - if (matches !== null) { - if (key === 'client_id') server.client.id = matches[ 1 ] - else if (key === 'client_secret') server.client.secret = matches[ 1 ] - else if (key === 'user_username') server.user.username = matches[ 1 ] - else if (key === 'user_password') server.user.password = matches[ 1 ] - } - } - - // Check if all required sentences are here - for (const key of Object.keys(serverRunString)) { - if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true - if (serverRunString[ key ] === false) dontContinue = true - } - - // If no, there is maybe one thing not already initialized (client/user credentials generation...) - if (dontContinue === true) return - - server.app.stdout.removeListener('data', onStdout) - - process.on('exit', () => { - try { - process.kill(server.app.pid) - } catch { /* empty */ } - }) - - res(server) - }) + server.app = fork(join(root(), 'dist', 'server.js'), args, options) + server.app.stdout.on('data', function onStdout (data) { + let dontContinue = false + + // Capture things if we want to + for (const key of Object.keys(regexps)) { + const regexp = regexps[ key ] + const matches = data.toString().match(regexp) + if (matches !== null) { + if (key === 'client_id') server.client.id = matches[ 1 ] + else if (key === 'client_secret') server.client.secret = matches[ 1 ] + else if (key === 'user_username') server.user.username = matches[ 1 ] + else if (key === 'user_password') server.user.password = matches[ 1 ] + } + } + + // Check if all required sentences are here + for (const key of Object.keys(serverRunString)) { + if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true + if (serverRunString[ key ] === false) dontContinue = true + } + + // If no, there is maybe one thing not already initialized (client/user credentials generation...) + if (dontContinue === true) return + + server.app.stdout.removeListener('data', onStdout) + + process.on('exit', () => { + try { + process.kill(server.app.pid) + } catch { /* empty */ } }) + + res(server) + }) }) }