Browse Source

Add option to acceptance test runners to set a custom timeout multiplier

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
tags/v12.0.0beta2
Daniel Calviño Sánchez 7 years ago
parent
commit
4fc9a7146b
2 changed files with 48 additions and 1 deletions
  1. 31
    0
      tests/acceptance/run-local.sh
  2. 17
    1
      tests/acceptance/run.sh

+ 31
- 0
tests/acceptance/run-local.sh View File

@@ -39,6 +39,21 @@ set -o errexit
# Behat through Composer or running Behat) expect that.
cd "$(dirname $0)"

# "--timeout-multiplier N" option can be provided before any other parameter to
# set the timeout multiplier to be used in ActorContext.
TIMEOUT_MULTIPLIER=""
if [ "$1" = "--timeout-multiplier" ]; then
if [[ ! "$2" =~ ^[0-9]+$ ]]; then
echo "--timeout-multiplier must be followed by a positive integer"

exit 1
fi

TIMEOUT_MULTIPLIER=$2

shift 2
fi

# Safety parameter to prevent executing this script by mistake and messing with
# the Git repository.
if [ "$1" != "allow-git-repository-modifications" ]; then
@@ -49,6 +64,22 @@ fi

SCENARIO_TO_RUN=$2

if [ "$TIMEOUT_MULTIPLIER" != "" ]; then
# Although Behat documentation states that using the BEHAT_PARAMS
# environment variable "You can set any value for any option that is
# available in a behat.yml file" this is currently not true for the
# constructor parameters of contexts (see
# https://github.com/Behat/Behat/issues/983). Thus, the default "behat.yml"
# configuration file has to be adjusted to provide the appropriate
# parameters for ActorContext.
ORIGINAL="\
- ActorContext"
REPLACEMENT="\
- ActorContext:\n\
actorTimeoutMultiplier: $TIMEOUT_MULTIPLIER"
sed --in-place "s/$ORIGINAL/$REPLACEMENT/" config/behat.yml
fi

composer install

cd ../../

+ 17
- 1
tests/acceptance/run.sh View File

@@ -197,6 +197,22 @@ trap cleanUp EXIT
# the Git working directory to the container) expect that.
cd "$(dirname $0)"

# "--timeout-multiplier N" option can be provided before the specific scenario
# to run, if any, to set the timeout multiplier to be used in the acceptance
# tests.
TIMEOUT_MULTIPLIER_OPTION=""
if [ "$1" = "--timeout-multiplier" ]; then
if [[ ! "$2" =~ ^[0-9]+$ ]]; then
echo "--timeout-multiplier must be followed by a positive integer"

exit 1
fi

TIMEOUT_MULTIPLIER_OPTION="--timeout-multiplier $2"

shift 2
fi

# If no parameter is provided to this script all the acceptance tests are run.
SCENARIO_TO_RUN=$1

@@ -206,4 +222,4 @@ prepareSelenium
prepareDocker

echo "Running tests"
docker exec $NEXTCLOUD_LOCAL_CONTAINER bash -c "cd nextcloud && tests/acceptance/run-local.sh allow-git-repository-modifications $SCENARIO_TO_RUN"
docker exec $NEXTCLOUD_LOCAL_CONTAINER bash -c "cd nextcloud && tests/acceptance/run-local.sh $TIMEOUT_MULTIPLIER_OPTION allow-git-repository-modifications $SCENARIO_TO_RUN"

Loading…
Cancel
Save