Skip to content

Commit

Permalink
Merge pull request #23 from wp-cli/v2-prep
Browse files Browse the repository at this point in the history
Adapt test suite to fit v2 architecture
  • Loading branch information
schlessera authored Aug 6, 2018
2 parents 24e3ec8 + e2bf03d commit fd150ea
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 71 deletions.
56 changes: 31 additions & 25 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -1,144 +1,150 @@
# behat.yml
# WP-CLI framework
# WP-CLI bundle
default:
paths:
features: 'vendor/wp-cli/wp-cli-bundle/features'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# WP-CLI framework
wp-cli/wp-cli:
paths:
features: 'vendor/wp-cli/wp-cli/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp cache
wp-cli/cache-command:
paths:
features: 'vendor/wp-cli/cache-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp checksum
wp-cli/checksum-command:
paths:
features: 'vendor/wp-cli/checksum-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp config
wp-cli/config-command:
paths:
features: 'vendor/wp-cli/config-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp core
wp-cli/core-command:
paths:
features: 'vendor/wp-cli/core-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp cron
wp-cli/cron-command:
paths:
features: 'vendor/wp-cli/cron-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp db
wp-cli/db-command:
paths:
features: 'vendor/wp-cli/db-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp embed
wp-cli/embed-command:
paths:
features: 'vendor/wp-cli/embed-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp comment | wp menu | wp network | wp option | wp post | wp site | wp taxonomy | wp term | wp user
wp-cli/entity-command:
paths:
features: 'vendor/wp-cli/entity-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp eval
wp-cli/eval-command:
paths:
features: 'vendor/wp-cli/eval-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp export
wp-cli/export-command:
paths:
features: 'vendor/wp-cli/export-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp plugin | wp theme
wp-cli/extension-command:
paths:
features: 'vendor/wp-cli/extension-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp import
wp-cli/import-command:
paths:
features: 'vendor/wp-cli/import-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp language
wp-cli/language-command:
paths:
features: 'vendor/wp-cli/language-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp media
wp-cli/media-command:
paths:
features: 'vendor/wp-cli/media-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp package
wp-cli/package-command:
paths:
features: 'vendor/wp-cli/package-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp rewrite
wp-cli/rewrite-command:
paths:
features: 'vendor/wp-cli/rewrite-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp role
wp-cli/role-command:
paths:
features: 'vendor/wp-cli/role-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp scaffold
wp-cli/scaffold-command:
paths:
features: 'vendor/wp-cli/scaffold-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp search-replace
wp-cli/search-replace-command:
paths:
features: 'vendor/wp-cli/search-replace-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp server
wp-cli/server-command:
paths:
features: 'vendor/wp-cli/server-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp shell
wp-cli/shell-command:
paths:
features: 'vendor/wp-cli/shell-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp super-admin
wp-cli/super-admin-command:
paths:
features: 'vendor/wp-cli/super-admin-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'

# wp widget
wp-cli/widget-command:
paths:
features: 'vendor/wp-cli/widget-command/features'
bootstrap: 'vendor/wp-cli/wp-cli/features/bootstrap'
bootstrap: 'vendor/wp-cli/wp-cli-tests/features/bootstrap'
27 changes: 17 additions & 10 deletions ci/test.sh → bin/bootstrap-test-suite
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@

set -e

BUILD_DIR=$(pwd)
BUILD_DIR="$(pwd)"

if [ ${TRAVIS_BUILD_DIR+x} ]; then
BUILD_DIR="$TRAVIS_BUILD_DIR"
if [ -z "$WP_VERSION" ]; then
export WP_VERSION="latest"
fi

if [ $WP_VERSION = "latest" ]; then
export WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")
if [ "${TRAVIS_BUILD_DIR+x}" ]; then
BUILD_DIR="$TRAVIS_BUILD_DIR"
fi

if [ ${TEST_PACKAGE+x} ]; then
echo "Running source package tests..."
$BUILD_DIR/ci/test-package.sh
if [ "$WP_VERSION" = "latest" ]; then
echo "WP_VERSION set to 'latest', detecting actual version number..."
export WP_VERSION="$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")"
echo "WP_VERSION => $WP_VERSION"
fi

if [ ${TEST_PHAR+x} ]; then
if [ "${TEST_PHAR+x}" ]; then
echo "Running Phar distribution tests..."
$BUILD_DIR/ci/test-phar.sh
bin/test-phar
exit
fi

if [ "${TEST_PACKAGE+x}" ]; then
echo "Running source package tests..."
bin/test-source
fi
54 changes: 54 additions & 0 deletions bin/run-test-suite
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# The tests to be run are selected based on the $TEST_PACKAGE and $TEST_PHAR
# environment variables.
#
# $TEST_PACKAGE enables tests against source packages. You can select which
# commands/packages to test.
#
# The following options can be set:
#
# - "none": No packages are tested.
# - "all": The framework as well as all bundled commands are tested.
# - "commands": Only the command packages are tested.
# - <package name>: Only the package named <package name> is tested.
#
# $TEST_PHAR enables tests against the Phar distributions. You can select which
# distribution to test. The selected distribution will be tested against all
# bundled commands/packages.
#
# The following options can be set:
#
# - "none": Skip phar testing.
# - "nightly": Use the nightly phar.
# - "stable": Use the latest stable phar release.
# - "all": Use both the latest stable release phar as well as the nightly phar.

set -e

export BUILD_DIR="${TRAVIS_BUILD_DIR:-$(pwd)}"

if [ -z "$WP_VERSION" ]; then
export WP_VERSION="latest"
fi

if [ -z "$TEST_PACKAGE" ]; then
export TEST_PACKAGE="all"
fi

if [ "$WP_VERSION" = "latest" ]; then
echo "WP_VERSION set to 'latest', detecting actual version number..."
export WP_VERSION="$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")"
echo "WP_VERSION => $WP_VERSION"
fi

if [ "${TEST_PHAR+x}" ]; then
echo "Running Phar distribution tests..."
"${BUILD_DIR}/bin/test-phar"
exit
fi

if [ "${TEST_PACKAGE+x}" ]; then
echo "Running source package tests..."
"${BUILD_DIR}/bin/test-source"
fi
15 changes: 10 additions & 5 deletions ci/test-phar.sh → bin/test-phar
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ FAILED_PACKAGES=""
RELEASES=""
REPOS=""

if [ -z "$BUILD_DIR" ]; then
export BUILD_DIR="${TRAVIS_BUILD_DIR:-$(pwd)}"
fi

if [ -z "$TEST_PACKAGE" ]; then
TEST_PACKAGE="all"
fi
Expand All @@ -29,11 +33,11 @@ fi
if [ "$TEST_PACKAGE" == "all" ]; then
REPOS="wp-cli/wp-cli-bundle
wp-cli/wp-cli
$(cat vendor/wp-cli/wp-cli/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
$(cat ${BUILD_DIR}/vendor/wp-cli/wp-cli-bundle/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
fi

if [ "$TEST_PACKAGE" == "commands" ]; then
REPOS="$(cat vendor/wp-cli/wp-cli/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
REPOS="$(cat ${BUILD_DIR}/vendor/wp-cli/wp-cli-bundle/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
fi

if [ "$TEST_PACKAGE" != "all" -a "$TEST_PACKAGE" != "commands" ]; then
Expand Down Expand Up @@ -87,20 +91,21 @@ for RELEASE in $RELEASES; do
export WP_CLI_BIN_DIR="${BIN_FOLDER}"
mv "${WP_CLI_BIN_DIR}/wp-cli.phar" "${WP_CLI_BIN_DIR}/wp"
chmod +x "${BIN_FOLDER}/wp"
echo "Using binary ${BIN_FOLDER}/wp"

for REPO in $REPOS; do

echo "Testing ${RELEASE}:${REPO}..."
BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=vendor/${REPO}/features php ci/behat-tags.php)
BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=${BUILD_DIR}/vendor/${REPO}/features php ${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php)
echo "Behat Tags: $BEHAT_TAGS"

BEHAT_PROFILE=""
if [ "$REPO" != "wp-cli/wp-cli" ]; then
if [ "$REPO" != "wp-cli/wp-cli-bundle" ]; then
BEHAT_PROFILE=" --profile $REPO"
fi

set +e
vendor/bin/behat --format progress $BEHAT_TAGS --strict $BEHAT_PROFILE
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict $BEHAT_PROFILE
if [ $? -ne 0 ]; then
FAILED_PACKAGES="$FAILED_PACKAGES ${RELEASE}:${REPO}"
fi
Expand Down
14 changes: 9 additions & 5 deletions ci/test-package.sh → bin/test-source
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ FAILED_PACKAGES=""

REPOS=""

if [ -z "$BUILD_DIR" ]; then
export BUILD_DIR="${TRAVIS_BUILD_DIR:-$(pwd)}"
fi

if [ -z "$TEST_PACKAGE" -o "$TEST_PACKAGE" == "none" ]; then
echo "Skipping feature tests completely."
exit 0
Expand All @@ -24,11 +28,11 @@ fi
if [ "$TEST_PACKAGE" == "all" ]; then
REPOS="wp-cli/wp-cli-bundle
wp-cli-/wp-cli
$(cat vendor/wp-cli/wp-cli/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
$(cat ${BUILD_DIR}/vendor/wp-cli/wp-cli-bundle/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
fi

if [ "$TEST_PACKAGE" == "commands" ]; then
REPOS="$(cat vendor/wp-cli/wp-cli/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
REPOS="$(cat ${BUILD_DIR}/vendor/wp-cli/wp-cli-bundle/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")"
fi

if [ "$TEST_PACKAGE" != "all" -a "$TEST_PACKAGE" != "commands" ]; then
Expand All @@ -39,16 +43,16 @@ for REPO in $REPOS; do

echo "Testing package $REPO..."

BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=vendor/${REPO}/features php ci/behat-tags.php)
BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=${BUILD_DIR}/vendor/${REPO}/features php ${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php)
echo "Behat Tags: $BEHAT_TAGS"

BEHAT_PROFILE=""
if [ "$REPO" != "wp-cli/wp-cli" ]; then
if [ "$REPO" != "wp-cli/wp-cli-bundle" ]; then
BEHAT_PROFILE=" --profile $REPO"
fi

set +e
vendor/bin/behat --format progress $BEHAT_TAGS --strict $BEHAT_PROFILE
"${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict $BEHAT_PROFILE
if [ $? -ne 0 ]; then
FAILED_PACKAGES="$FAILED_PACKAGES $REPO"
fi
Expand Down
Loading

0 comments on commit fd150ea

Please sign in to comment.