diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-05-03 18:24:30 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-05-04 00:18:40 +0300 |
commit | 4fc9a7146ba203f6c0a83da490ec65df2f388f22 (patch) | |
tree | 7b617ed223b3f66232c0051b02b83fbcf135d588 /tests/acceptance | |
parent | b10478ff19be0e4c38f8ff6b0c31f1a40eda0043 (diff) |
Add option to acceptance test runners to set a custom timeout multiplier
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance')
-rwxr-xr-x | tests/acceptance/run-local.sh | 31 | ||||
-rwxr-xr-x | tests/acceptance/run.sh | 18 |
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh index ee7a4e6455c..93c11e810f8 100755 --- a/tests/acceptance/run-local.sh +++ b/tests/acceptance/run-local.sh @@ -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 ../../ diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh index 42a718d46e2..1b68f8655ae 100755 --- a/tests/acceptance/run.sh +++ b/tests/acceptance/run.sh @@ -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" |