Skip to content

Commit

Permalink
Merge pull request #151 from wp-cli/fix/always-run-wp-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Oct 10, 2022
2 parents f5743cc + 1a3da51 commit 9e97a1e
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ public static function get_bin_path() {
* Get the environment variables required for launched `wp` processes
*/
private static function get_process_env_variables() {
static $env = null;

if ( null !== $env ) {
return $env;
}

// Ensure we're using the expected `wp` binary.
$bin_path = self::get_bin_path();
wp_cli_behat_env_debug( "WP-CLI binary path: {$bin_path}" );
Expand Down Expand Up @@ -333,30 +339,15 @@ public static function prepare( BeforeSuiteScope $scope ) {
}

$result = Process::create( 'wp cli info', null, self::get_process_env_variables() )->run_check();
echo PHP_EOL;
echo $result->stdout;
echo PHP_EOL;

if ( getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) {
exit;
}
echo "{$result->stdout}\n";

self::cache_wp_files();

$result = Process::create( Utils\esc_cmd( 'wp core version --debug --path=%s', self::$cache_dir ), null, self::get_process_env_variables() )->run_check();
echo "[Debug messages]\n";
echo "{$result->stderr}\n";

$ci = getenv( 'CI' );
$travis = getenv( 'TRAVIS' );
if ( $travis || $ci ) {
$travis && print( "travis_fold:start:wp_cli_debug\n" );
echo "[Debug messages]\n";
echo $result->stderr;
$travis && print( "travis_fold:end:wp_cli_debug\n" );
}

echo PHP_EOL;
echo 'WordPress ' . $result->stdout;
echo PHP_EOL;
echo "WordPress {$result->stdout}\n";

// Remove install cache if any (not setting the static var).
$wp_version = getenv( 'WP_VERSION' );
Expand All @@ -365,6 +356,10 @@ public static function prepare( BeforeSuiteScope $scope ) {
if ( file_exists( $install_cache_dir ) ) {
self::remove_dir( $install_cache_dir );
}

if ( getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) {
exit;
}
}

/**
Expand Down

0 comments on commit 9e97a1e

Please sign in to comment.