Skip to content

Commit 2176805

Browse files
committed
Update install-wp-tests script
1 parent cd1e49a commit 2176805

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

templates/install-wp-tests.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
# See https://raw.githubusercontent.com/wp-cli/scaffold-command/master/templates/install-wp-tests.sh
4+
35
if [ $# -lt 3 ]; then
46
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
57
exit 1
@@ -66,15 +68,15 @@ set -ex
6668

6769
install_wp() {
6870

69-
if [ -d $WP_CORE_DIR ]; then
71+
if [ -f $WP_CORE_FILE ]; then
7072
return;
7173
fi
7274

75+
rm -rf $WP_CORE_DIR
7376
mkdir -p $WP_CORE_DIR
7477

7578
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
7679
mkdir -p $TMPDIR/wordpress-trunk
77-
rm -rf $TMPDIR/wordpress-trunk/*
7880
check_svn_installed
7981
svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
8082
mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
@@ -103,8 +105,6 @@ install_wp() {
103105
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
104106
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
105107
fi
106-
107-
download https://raw.githubusercontent.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
108108
}
109109

110110
install_test_suite() {
@@ -115,11 +115,11 @@ install_test_suite() {
115115
local ioption='-i'
116116
fi
117117

118-
# set up testing suite if it doesn't yet exist
119-
if [ ! -d $WP_TESTS_DIR ]; then
118+
# set up testing suite if it doesn't yet exist or only partially exists
119+
if [ ! -f $WP_TESTS_FILE ]; then
120120
# set up testing suite
121+
rm -rf $WP_TESTS_DIR
121122
mkdir -p $WP_TESTS_DIR
122-
rm -rf $WP_TESTS_DIR/{includes,data}
123123
check_svn_installed
124124
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
125125
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
@@ -130,7 +130,6 @@ install_test_suite() {
130130
# remove all forward slashes in the end
131131
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
132132
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
133-
sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
134133
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
135134
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
136135
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
@@ -153,7 +152,11 @@ recreate_db() {
153152
}
154153

155154
create_db() {
156-
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
155+
if [ `which mariadb-admin` ]; then
156+
mariadb-admin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
157+
else
158+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
159+
fi
157160
}
158161

159162
install_db() {

0 commit comments

Comments
 (0)