Use parallel to run tests in parallel

This commit is contained in:
Chocobozzz
2020-07-30 14:44:08 +02:00
committed by Chocobozzz
parent b488ba1e26
commit 7abb5c5da1
7 changed files with 57 additions and 114 deletions

View File

@@ -9,42 +9,82 @@ fi
killall -q peertube || true
perl -0777 -i -pe 's#proxy:(\n\s+)enabled: false\n\s+url: ""#proxy:$1enabled: true$1url: "http://188.165.225.149:7899"#' config/test.yaml
retries=3
jobs=2
runTest () {
retries=3
jobs=$1
shift
files=$@
echo $files
MOCHA_PARALLEL=true parallel -t -j $jobs --retries $retries \
npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail \
::: $files
}
findTestFiles () {
find $1 -type f -name "*.ts" | grep -v index.ts | xargs echo
}
if [ "$1" = "misc" ]; then
npm run build -- --light
TS_NODE_FILES=true mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail \
server/tests/client.ts \
server/tests/feeds/index.ts \
server/tests/misc-endpoints.ts \
server/tests/helpers/index.ts \
server/tests/plugins/index.ts
feedsFiles=$(findTestFiles server/tests/feeds)
helperFiles=$(findTestFiles server/tests/helpers)
pluginsFiles=$(findTestFiles server/tests/plugins)
miscFiles=server/tests/client.ts server/tests/misc-endpoints.ts
TS_NODE_FILES=true runTest 2 $feedsFiles $helperFiles $pluginsFiles $miscFiles
elif [ "$1" = "cli" ]; then
npm run build:server
npm run setup:cli
mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/cli/index.ts
cliFiles=$(findTestFiles server/tests/cli)
runTest 1 $cliFiles
elif [ "$1" = "api-1" ]; then
npm run build:server
sh ./server/tests/api/ci-1.sh 2
checkParamFiles=$(findTestFiles server/tests/api/check-params)
notificationsFiles=$(findTestFiles server/tests/api/notifications)
searchFiles=$(findTestFiles server/tests/api/search)
runTest 2 $notificationsFiles $searchFiles $checkParamFiles
elif [ "$1" = "api-2" ]; then
npm run build:server
sh ./server/tests/api/ci-2.sh 2
serverFiles=$(findTestFiles server/tests/api/server)
usersFiles=$(findTestFiles server/tests/api/users)
runTest 2 $serverFiles $usersFiles
elif [ "$1" = "api-3" ]; then
npm run build:server
sh ./server/tests/api/ci-3.sh 2
videosFiles=$(findTestFiles server/tests/api/videos)
runTest 1 $videosFiles
elif [ "$1" = "api-4" ]; then
npm run build:server
sh ./server/tests/api/ci-4.sh 2
activitypubFiles=$(findTestFiles server/tests/api/moderation)
redundancyFiles=$(findTestFiles server/tests/api/redundancy)
activitypubFiles=$(findTestFiles server/tests/api/activitypub)
TS_NODE_FILES=true runTest 2 $activitypubFiles $redundancyFiles $activitypubFiles
elif [ "$1" = "external-plugins" ]; then
npm run build:server
mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/external-plugins/index.ts
externalPluginsFiles=$(findTestFiles server/tests/external-plugins)
runTest 1 $externalPluginsFiles
elif [ "$1" = "lint" ]; then
npm run eslint -- --ext .ts "server/**/*.ts" "shared/**/*.ts"
npm run eslint -- --ext .ts "server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
npm run swagger-cli -- validate support/doc/api/openapi.yaml
( cd client
npm run lint
)
fi
git checkout -- config/test.yaml