2017-04-16 11:39:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
|
|
|
#
|
|
|
|
# @license GNU AGPL version 3 or any later version
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Helper script to run the acceptance tests, which test a running Nextcloud
|
2017-04-19 05:58:18 +00:00
|
|
|
# instance from the point of view of a real user, configured to start the
|
|
|
|
# Nextcloud server themselves and from their grandparent directory.
|
2017-04-16 11:39:59 +00:00
|
|
|
#
|
|
|
|
# The acceptance tests are written in Behat so, besides running the tests, this
|
|
|
|
# script installs Behat, its dependencies, and some related packages in the
|
2017-04-18 18:24:46 +00:00
|
|
|
# "vendor" subdirectory of the acceptance tests. The acceptance tests expect
|
|
|
|
# that the last commit in the Git repository provides the default state of the
|
|
|
|
# Nextcloud server, so the script installs the Nextcloud server and saves a
|
|
|
|
# snapshot of the whole grandparent directory (no .gitignore file is used) in
|
|
|
|
# the Git repository. Finally, the acceptance tests also use the Selenium server
|
|
|
|
# to control a web browser, so this script waits for the Selenium server
|
2017-04-19 05:58:18 +00:00
|
|
|
# (which should have been started before executing this script) to be ready
|
|
|
|
# before running the tests.
|
2017-04-16 11:39:59 +00:00
|
|
|
|
|
|
|
# Exit immediately on errors.
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
# Ensure working directory is script directory, as some actions (like installing
|
|
|
|
# Behat through Composer or running Behat) expect that.
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
2017-04-19 06:15:51 +00:00
|
|
|
# Safety parameter to prevent executing this script by mistake and messing with
|
|
|
|
# the Git repository.
|
|
|
|
if [ "$1" != "allow-git-repository-modifications" ]; then
|
|
|
|
echo "To run the acceptance tests use \"run.sh\" instead"
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SCENARIO_TO_RUN=$2
|
2017-04-16 11:39:59 +00:00
|
|
|
|
|
|
|
composer install
|
|
|
|
|
2017-04-18 18:24:46 +00:00
|
|
|
cd ../../
|
2017-04-16 11:39:59 +00:00
|
|
|
|
2017-04-18 18:24:46 +00:00
|
|
|
echo "Installing and configuring Nextcloud server"
|
|
|
|
build/acceptance/installAndConfigureServer.sh
|
|
|
|
|
|
|
|
echo "Saving the default state so acceptance tests can reset to it"
|
|
|
|
find . -name ".gitignore" -exec rm --force {} \;
|
|
|
|
git add --all && echo 'Default state' | git -c user.name='John Doe' -c user.email='john@doe.org' commit --quiet --file=-
|
2017-04-16 11:39:59 +00:00
|
|
|
|
2017-04-18 18:24:46 +00:00
|
|
|
cd build/acceptance
|
2017-04-16 11:39:59 +00:00
|
|
|
|
2017-04-19 05:58:18 +00:00
|
|
|
# Ensure that the Selenium server is ready before running the tests.
|
2017-04-18 18:24:46 +00:00
|
|
|
echo "Waiting for Selenium"
|
|
|
|
timeout 60s bash -c "while ! curl 127.0.0.1:4444 >/dev/null 2>&1; do sleep 1; done"
|
2017-04-16 11:39:59 +00:00
|
|
|
|
2017-04-19 06:05:40 +00:00
|
|
|
vendor/bin/behat $SCENARIO_TO_RUN
|