From 0bbef54c84760fdf00c4bef8359dbced2826f273 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 | 19 +++++++++++++------ runners/behat/before_script.sh | 2 +- runners/phpunit-core/before_script.sh | 5 +---- runners/simpletest/before_script.sh | 2 +- 6 files changed, 16 insertions(+), 21 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..9ac82ba 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,23 @@ 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 drupal_ti_install_drupal + touch "$TRAVIS_BUILD_DIR/../drupal_ti-drupal-installed" } # 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"