Skip to content

Commit 851e1cf

Browse files
authored
revert: the comments
1 parent 19d2df5 commit 851e1cf

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

templates/install-wp-tests.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ if ! command -v svn &> /dev/null; then
3535
exit 1
3636
fi
3737

38+
# Set WP_TESTS_TAG based on WP_VERSION
3839
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
3940
WP_BRANCH=${WP_VERSION%\-*}
4041
WP_TESTS_TAG="branches/$WP_BRANCH"
4142
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
4243
WP_TESTS_TAG="branches/$WP_VERSION"
4344
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
4445
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
46+
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
4547
WP_TESTS_TAG="tags/${WP_VERSION%??}"
4648
else
4749
WP_TESTS_TAG="tags/$WP_VERSION"
4850
fi
4951
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
5052
WP_TESTS_TAG="trunk"
5153
else
54+
# Download latest version if no specific version is provided
5255
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
5356
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
5457
if [[ -z "$LATEST_VERSION" ]]; then
@@ -57,8 +60,10 @@ else
5760
fi
5861
WP_TESTS_TAG="tags/$LATEST_VERSION"
5962
fi
63+
6064
set -ex
6165

66+
# Install WordPress core
6267
install_wp() {
6368

6469
if [ -d $WP_CORE_DIR ]; then
@@ -98,20 +103,25 @@ install_wp() {
98103
download https://raw.githubusercontent.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
99104
}
100105

106+
# Install the WordPress test suite
101107
install_test_suite() {
108+
# portable in-place argument for both GNU sed and Mac OSX sed
102109
if [[ $(uname -s) == 'Darwin' ]]; then
103110
local ioption='-i.bak'
104111
else
105112
local ioption='-i'
106113
fi
107114

115+
# set up testing suite if it doesn't yet exist
108116
if [ ! -d $WP_TESTS_DIR ]; then
117+
# set up testing suite
109118
mkdir -p $WP_TESTS_DIR
110119
rm -rf $WP_TESTS_DIR/{includes,data}
111120
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
112121
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
113122
fi
114123

124+
# Configure wp-tests-config.php
115125
if [ ! -f wp-tests-config.php ]; then
116126
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
117127
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
@@ -124,9 +134,11 @@ install_test_suite() {
124134
fi
125135
}
126136

137+
# Recreate the database if needed
127138
recreate_db() {
128139
shopt -s nocasematch
129-
if [[ $1 =~ ^(y|yes)$ ]]; then
140+
if [[ $1 =~ ^(y|yes)$ ]]
141+
then
130142
mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA
131143
create_db
132144
echo "Recreated the database ($DB_NAME)."
@@ -136,31 +148,37 @@ recreate_db() {
136148
shopt -u nocasematch
137149
}
138150

151+
# Create the database
139152
create_db() {
140153
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
141154
}
142155

156+
# Install the test database
143157
install_db() {
158+
144159
if [ ${SKIP_DB_CREATE} = "true" ]; then
145160
return 0
146161
fi
147162

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

153-
if ! [ -z $DB_HOSTNAME ]; then
169+
if ! [ -z $DB_HOSTNAME ] ; then
154170
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
155171
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
156-
elif ! [ -z $DB_SOCK_OR_PORT ]; then
172+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
157173
EXTRA=" --socket=$DB_SOCK_OR_PORT"
158-
elif ! [ -z $DB_HOSTNAME ]; then
174+
elif ! [ -z $DB_HOSTNAME ] ; then
159175
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
160176
fi
161177
fi
162178

163-
if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]; then
179+
# create database
180+
if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]
181+
then
164182
echo "Reinstalling will delete the existing test database ($DB_NAME)"
165183
read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
166184
recreate_db $DELETE_EXISTING_DB
@@ -169,6 +187,7 @@ install_db() {
169187
fi
170188
}
171189

190+
# Run the installation functions
172191
install_wp
173192
install_test_suite
174193
install_db

0 commit comments

Comments
 (0)