From 19e9c3ddbc873d99b75273b8fb56a714fb6a29c6 Mon Sep 17 00:00:00 2001 From: yanniboi Date: Mon, 23 Jan 2017 10:24:49 +0000 Subject: [PATCH] Issue #38: Restructured drupal_ti_ensure_drupal and sub functions for backward compatibility. --- environments/drupal-7.sh | 5 ----- environments/drupal-8.sh | 4 ---- functions/drupal.sh | 24 ++++++++++++++++-------- runners/behat/before_script.sh | 2 +- runners/phpunit-core/before_script.sh | 5 +---- runners/simpletest/before_script.sh | 2 +- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/environments/drupal-7.sh b/environments/drupal-7.sh index 04bda49..db77cd9 100644 --- a/environments/drupal-7.sh +++ b/environments/drupal-7.sh @@ -7,11 +7,6 @@ function drupal_ti_download_drupal() { } function drupal_ti_install_drupal() { - if [ ! -f install.php ] - then - return -1 - fi - php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL" drush use $(pwd)#default } diff --git a/environments/drupal-8.sh b/environments/drupal-8.sh index 8fe0b9e..359e07f 100644 --- a/environments/drupal-8.sh +++ b/environments/drupal-8.sh @@ -9,10 +9,6 @@ function drupal_ti_download_drupal() { } function drupal_ti_install_drupal() { - if [ ! -f install.php ] - then - return -1 - fi php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes -v site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL" drush use $(pwd)#default } diff --git a/functions/drupal.sh b/functions/drupal.sh index 3115228..15cee32 100644 --- a/functions/drupal.sh +++ b/functions/drupal.sh @@ -3,9 +3,9 @@ # Common functionality for common tasks. # -# Ensures that the right Drupal version exists. +# Ensures that the right Drupal version is downloaded. # -function drupal_ti_ensure_drupal() { +function drupal_ti_ensure_drupal_download() { # This function is re-entrant. if [ -d "$DRUPAL_TI_DRUPAL_DIR" ] then @@ -30,16 +30,24 @@ function drupal_ti_ensure_drupal() { } # -# Ensures that Drupal is installed. +# Ensures that the right Drupal version is installed. # -function drupal_ti_ensure_drupal_installed() { - drupal_ti_ensure_drupal +function drupal_ti_ensure_drupal() { + # This function is re-entrant. + drupal_ti_ensure_drupal_download + + # @todo Maybe use a different check for Drupal installed. + if [ -r "$TRAVIS_BUILD_DIR/../drupal_ti-drupal-installed" ] + then + return + fi # Create database and install Drupal. mysql -e "create database $DRUPAL_TI_DB" - cd drupal + cd "$DRUPAL_TI_DRUPAL_DIR" drupal_ti_install_drupal + touch "$TRAVIS_BUILD_DIR/../drupal_ti-drupal-installed" } # @@ -91,14 +99,14 @@ function drupal_ti_run_server() { # Use hhvm_serve for PHP 5.3 fcgi and hhvm fcgi PHP_VERSION=$(phpenv version-name) + export DRUPAL_TI_WEBSERVER_HOST=$(echo "$DRUPAL_TI_WEBSERVER_URL" | sed 's,http://,,') if [ "$PHP_VERSION" = "5.3" -o "$PHP_VERSION" = "hhvm" ] then export GOPATH="$DRUPAL_TI_DIST_DIR/go" - export DRUPAL_TI_WEBSERVER_HOST=$(echo "$DRUPAL_TI_WEBSERVER_URL" | sed 's,http://,,') { "$GOPATH/bin/hhvm-serve" -listen="$DRUPAL_TI_WEBSERVER_HOST:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } & else # start a web server on port 8080, run in the background; wait for initialization - { drush runserver "$DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } & + { php -S "$DRUPAL_TI_WEBSERVER_HOST:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } & fi # Wait until drush server has been started. diff --git a/runners/behat/before_script.sh b/runners/behat/before_script.sh index 7afe134..cebdd15 100755 --- a/runners/behat/before_script.sh +++ b/runners/behat/before_script.sh @@ -4,7 +4,7 @@ set -e $DRUPAL_TI_DEBUG # Ensure the right Drupal version is installed. -drupal_ti_ensure_drupal_installed +drupal_ti_ensure_drupal # Ensure the module is linked into the code base and enabled. drupal_ti_ensure_module diff --git a/runners/phpunit-core/before_script.sh b/runners/phpunit-core/before_script.sh index d61d072..c19f3af 100755 --- a/runners/phpunit-core/before_script.sh +++ b/runners/phpunit-core/before_script.sh @@ -4,10 +4,7 @@ set -e $DRUPAL_TI_DEBUG # Ensure the right Drupal version is downloaded. -drupal_ti_ensure_drupal - -# Change directory to Drupal core directory. -cd drupal +drupal_ti_ensure_drupal_download # Ensure the module is linked into the code base. drupal_ti_ensure_module_linked diff --git a/runners/simpletest/before_script.sh b/runners/simpletest/before_script.sh index 1876359..5a526b6 100755 --- a/runners/simpletest/before_script.sh +++ b/runners/simpletest/before_script.sh @@ -4,7 +4,7 @@ set -e $DRUPAL_TI_DEBUG # Ensure the right Drupal version is installed. -drupal_ti_ensure_drupal_installed +drupal_ti_ensure_drupal # Enable simpletest module. cd "$DRUPAL_TI_DRUPAL_DIR"