From 03d7be7b4849eff723c9f61b1d400ec7aea75245 Mon Sep 17 00:00:00 2001 From: Dave Koston Date: Wed, 11 Dec 2024 10:38:53 -0600 Subject: [PATCH] behat: Use dmarynicz/behat-parallel-extension to run tests in parallel when BEHAT_PARALLEL is set --- behat.yml | 2 ++ bin/run-behat-tests | 8 +++++++- composer.json | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/behat.yml b/behat.yml index d6ee86224..1af05c93b 100644 --- a/behat.yml +++ b/behat.yml @@ -5,3 +5,5 @@ default: - WP_CLI\Tests\Context\FeatureContext paths: - features + extensions: + DMarynicz\BehatParallelExtension\Extension: ~ diff --git a/bin/run-behat-tests b/bin/run-behat-tests index f9a09bc15..428698a85 100755 --- a/bin/run-behat-tests +++ b/bin/run-behat-tests @@ -19,6 +19,12 @@ if [[ "$@" == *"--help"* ]]; then exit $ret fi +PARALLEL="" +if [[ -n "${BEHAT_PARALLEL}" ]]; then + PARALLEL="--parallel" +fi + + # Turn WP_VERSION into an actual number to make sure our tags work correctly. if [ "${WP_VERSION-latest}" = "latest" ]; then export WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current") @@ -45,4 +51,4 @@ export WP_CLI_TESTS_ROOT BEHAT_TAGS=$(php "$WP_CLI_TESTS_ROOT"/utils/behat-tags.php) # Run the functional tests. -vendor/bin/behat --format progress "$BEHAT_TAGS" --strict "$@" +vendor/bin/behat "${PARALLEL}" --format progress "$BEHAT_TAGS" --strict "$@" diff --git a/composer.json b/composer.json index 7546d154b..147413831 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "php": ">=5.6", "behat/behat": "^3.7", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7.1 || ^1.0.0", + "dmarynicz/behat-parallel-extension": "^1.0", "php-parallel-lint/php-console-highlighter": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.3.1", "phpcompatibility/php-compatibility": "dev-develop",