Skip to content

Commit

Permalink
[CMSP-678]:Shellcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Wagner committed Oct 11, 2023
1 parent 36db229 commit 8c1e0fa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bin/behat-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ set -ex
###
# Delete the environment used for this test run.
###
terminus multidev:delete $SITE_ENV --delete-branch --yes
terminus multidev:delete "$SITE_ENV" --delete-branch --yes
36 changes: 18 additions & 18 deletions bin/behat-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,58 +27,58 @@ set -ex
###
# Create a new environment for this particular test run.
###
terminus env:create $TERMINUS_SITE.dev $TERMINUS_ENV
terminus env:wipe $SITE_ENV --yes
terminus env:create "$TERMINUS_SITE".dev "$TERMINUS_ENV"
terminus env:wipe "$SITE_ENV" --yes

###
# Get all necessary environment details.
###
PANTHEON_GIT_URL=$(terminus connection:info $SITE_ENV --field=git_url)
PANTHEON_GIT_URL=$(terminus connection:info "$SITE_ENV" --field=git_url)
PANTHEON_SITE_URL="$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io"
PREPARE_DIR="/tmp/$TERMINUS_ENV-$TERMINUS_SITE"
BASH_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

###
# Switch to git mode for pushing the files up
###
terminus connection:set $SITE_ENV git
rm -rf $PREPARE_DIR
git clone -b $TERMINUS_ENV $PANTHEON_GIT_URL $PREPARE_DIR
terminus connection:set "$SITE_ENV" git
rm -rf "$PREPARE_DIR"
git clone -b "$TERMINUS_ENV" "$PANTHEON_GIT_URL" "$PREPARE_DIR"

###
# Add the copy of this plugin itself to the environment
###
rm -rf $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions
cd $BASH_DIR/..
rsync -av --exclude='vendor/' --exclude='node_modules/' --exclude='tests/' ./* $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions
rm -rf $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions/.git
rm -rf "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions
cd "$BASH_DIR"/..
rsync -av --exclude='vendor/' --exclude='node_modules/' --exclude='tests/' ./* "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions
rm -rf "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions/.git

###
# Add the debugging plugin to the environment
###
rm -rf $PREPARE_DIR/wp-content/mu-plugins/sessions-debug.php
cp $BASH_DIR/fixtures/sessions-debug.php $PREPARE_DIR/wp-content/mu-plugins/sessions-debug.php
rm -rf "$PREPARE_DIR"/wp-content/mu-plugins/sessions-debug.php
cp "$BASH_DIR"/fixtures/sessions-debug.php "$PREPARE_DIR"/wp-content/mu-plugins/sessions-debug.php

###
# Push files to the environment
###
cd $PREPARE_DIR
cd "$PREPARE_DIR"
git add wp-content
git config user.email "[email protected]"
git config user.name "Pantheon"
git commit -m "Include WP Native PHP Sessions and its configuration files"
git push

# Sometimes Pantheon takes a little time to refresh the filesystem
terminus build:workflow:wait $TERMINUS_SITE.$TERMINUS_ENV
terminus build:workflow:wait "$TERMINUS_SITE"."$TERMINUS_ENV"

###
# Set up WordPress, theme, and plugins for the test run
###
# Silence output so as not to show the password.
{
terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME [email protected] --admin_password=$WORDPRESS_ADMIN_PASSWORD
terminus wp "$SITE_ENV" -- core install --title="$TERMINUS_ENV"-"$TERMINUS_SITE" --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME [email protected] --admin_password="$WORDPRESS_ADMIN_PASSWORD"
} &> /dev/null
terminus wp $SITE_ENV -- plugin activate wp-native-php-sessions
terminus wp $SITE_ENV -- theme activate twentytwentythree
terminus wp $SITE_ENV -- rewrite structure '/%year%/%monthnum%/%day%/%postname%/'
terminus wp "$SITE_ENV" -- plugin activate wp-native-php-sessions
terminus wp "$SITE_ENV" -- theme activate twentytwentythree
terminus wp "$SITE_ENV" -- rewrite structure '/%year%/%monthnum%/%day%/%postname%/'
12 changes: 6 additions & 6 deletions bin/full-teardown-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}

file_delete() {
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
rm -rf "$WP_TESTS_DIR" "$WP_CORE_DIR"
}

drop_db() {

# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local PARTS=("${DB_HOST//\:/ }")
local DB_HOSTNAME=${PARTS[0]};
local DB_SOCK_OR_PORT=${PARTS[1]};
local EXTRA=""

if ! [ -z $DB_HOSTNAME ] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
if [ $(echo "$DB_SOCK_OR_PORT" | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
elif ! [ -z "$DB_SOCK_OR_PORT" ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
elif ! [ -z $DB_HOSTNAME ] ; then
elif ! [ -z "$DB_HOSTNAME" ] ; then
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
fi
fi

# create database
echo Y | mysqladmin drop $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
echo Y | mysqladmin drop "$DB_NAME" --user="$DB_USER" --password="$DB_PASS""$EXTRA"
}

file_delete
Expand Down
2 changes: 1 addition & 1 deletion bin/phpunit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DIRNAME=$(dirname "$0")
bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 latest
echo "Running PHPUnit on Single Site"
composer phpunit
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
rm -rf "$WP_TESTS_DIR" "$WP_CORE_DIR"

bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 nightly true
echo "Running PHPUnit on Single Site (Nightly WordPress)"
Expand Down
5 changes: 3 additions & 2 deletions bin/validate-fixture-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ IFS=$'\n\t'

main(){
export TERMINUS_HIDE_GIT_MODE_WARNING=1
local DIRNAME=$(dirname "$0")
local DIRNAME
DIRNAME=$(dirname "$0")

if [ -z "${TERMINUS_SITE}" ]; then
echo "TERMINUS_SITE environment variable must be set"
Expand All @@ -20,7 +21,7 @@ main(){
fi

# Use find to locate the file with a case-insensitive search
README_FILE_PATH=$(find ${DIRNAME}/.. -iname "readme.txt" -print -quit)
README_FILE_PATH=$(find "${DIRNAME}"/.. -iname "readme.txt" -print -quit)
if [[ -z "$README_FILE_PATH" ]]; then
echo "readme.txt not found."
exit 1
Expand Down

0 comments on commit 8c1e0fa

Please sign in to comment.