diff --git a/.env.default b/.env.default index 33b49c1..204398a 100644 --- a/.env.default +++ b/.env.default @@ -57,9 +57,16 @@ export WPT_SSH_OPTIONS="" # SSH private key, base64 encoded. export WPT_SSH_PRIVATE_KEY_BASE64="" -# Output logging -# Use 'verbose' to increase verbosity -export WPT_DEBUG="" +# Whether to enable debug Mode. +# +# Enabling debug mode will output verbose logging and details about each part +# of the test runner. +# +# 0 = Debug mode off +# 1 = Debug mode on +# +# Any other truthy value will also enable debug mode. +export WPT_DEBUG= # Certificate validation # Use 1 to validate, and 0 to not validate diff --git a/cleanup.php b/cleanup.php index e584c6c..a0d8ad0 100644 --- a/cleanup.php +++ b/cleanup.php @@ -16,27 +16,21 @@ check_required_env(); /** - * Retrieves environment variables and sets defaults for test preparation. - * These variables are used to configure SSH connections, file paths, and - * executable commands needed for setting up the test environment. + * Ensure that all environment variables are present with default values. */ -$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); -$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); -$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; -$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); -$WPT_RM_TEST_DIR_CMD = trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ? : 'rm -r ' . $WPT_TEST_DIR; +$runner_vars = setup_runner_env_vars(); /** * The directory path of the test preparation directory is assumed to be previously defined. - * For example: $WPT_PREPARE_DIR = '/path/to/your/preparation/dir'; + * For example: $runner_vars['WPT_PREPARE_DIR'] = '/path/to/your/preparation/dir'; * Clean up the preparation directory. * Forcefully deletes only the .git directory and the node_modules cache. * Afterward, the entire preparation directory is removed to ensure a clean state for the next test run. */ perform_operations( array( - 'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/.git' ), - 'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/node_modules/.cache' ), - 'rm -r ' . escapeshellarg( $WPT_PREPARE_DIR ), + 'rm -rf ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] . '/.git' ), + 'rm -rf ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] . '/node_modules/.cache' ), + 'rm -r ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ), ) ); /** @@ -46,8 +40,8 @@ * The cleanup operation is executed by the `perform_operations` function which takes an array * of shell commands as its input. */ -if ( ! empty( $WPT_SSH_CONNECT ) ) { +if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { perform_operations( array( - 'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $WPT_RM_TEST_DIR_CMD ), + 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . escapeshellarg( $runner_vars['WPT_RM_TEST_DIR_CMD'] ), ) ); } diff --git a/functions.php b/functions.php index a9613aa..88b005d 100644 --- a/functions.php +++ b/functions.php @@ -43,6 +43,67 @@ function check_required_env( $check_db = true ) { log_message( 'Environment variables pass checks.' ); } +/** + * Parses environment variables used to configure the test runner. + * + * @return array[] { + * Test runner configuration options. + * + * @type array ...$0 { + * An associative array of test runner configuration options. + * + * @type string $WPT_TEST_DIR Path to the directory where wordpress-develop is placed for testing + * after being prepared. Default '/tmp/wp-test-runner'. + * @type string $WPT_PREPARE_DIR Path to the temporary directory where wordpress-develop is cloned + * and configured. Default '/tmp/wp-test-runner'. + * @type string $WPT_SSH_CONNECT List of inner blocks. An array of arrays that + * have the same structure as this one. + * @type string $WPT_SSH_OPTIONS HTML from inside block comment delimiters. + * @type string $WPT_PHP_EXECUTABLE List of string fragments and null markers where + * inner blocks were found. + * @type string $WPT_RM_TEST_DIR_CMD Command for removing the test directory. + * @type string $WPT_REPORT_API_KEY API key for submitting test results. + * @type bool $WPT_CERTIFICATE_VALIDATION Whether to validate TLS certificates. Default true. + * @type bool $WPT_DEBUG_MODE Whether debug mode is enabled. + * } + * } + */ +function setup_runner_env_vars() { + // Set the test directory first as it's needed for processing other variables. + $runner_configuration = array( + 'WPT_TEST_DIR' => trim( getenv( 'WPT_TEST_DIR' ) ) ?: '/tmp/wp-test-runner', + ); + + /* + * When no value is provided for WPT_CERTIFICATE_VALIDATION, assume that the default of true (validate certificates) + * is desired. + */ + if ( false === getenv( 'WPT_CERTIFICATE_VALIDATION' ) ) { + $runner_configuration['WPT_CERTIFICATE_VALIDATION'] = true; + } else { + $runner_configuration['WPT_CERTIFICATE_VALIDATION'] = (bool) getenv( 'WPT_CERTIFICATE_VALIDATION' ); + } + + return array_merge( + $runner_configuration, + array( + // Directory configuration + 'WPT_PREPARE_DIR' => trim( getenv( 'WPT_PREPARE_DIR' ) ) ?: '/tmp/wp-test-runner', + // SSH connection configuration + 'WPT_SSH_CONNECT' => trim( getenv( 'WPT_SSH_CONNECT' ) ), + 'WPT_SSH_OPTIONS' => trim( getenv( 'WPT_SSH_OPTIONS' ) ) ?: '-o StrictHostKeyChecking=no', + // Test execution configuration + 'WPT_PHP_EXECUTABLE' => trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ?: 'php', + // Cleanup configuration + 'WPT_RM_TEST_DIR_CMD' => trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ?: 'rm -r ' . $runner_configuration['WPT_TEST_DIR'], + // Reporting configuration + 'WPT_REPORT_API_KEY' => trim( getenv( 'WPT_REPORT_API_KEY' ) ), + // Miscellaneous + 'WPT_DEBUG' => (bool) getenv( 'WPT_DEBUG' ), + ) + ); +} + /** * Executes a series of shell commands provided in the operations array. Each operation is logged before execution. * If any command fails (indicated by a non-zero return code), an error message is displayed. This function is diff --git a/prepare.php b/prepare.php index bea7cf4..4ceae13 100644 --- a/prepare.php +++ b/prepare.php @@ -18,37 +18,9 @@ check_required_env(); /** - * Retrieves environment variables and sets defaults for test preparation. - * These variables are used to configure SSH connections, file paths, and - * executable commands needed for setting up the test environment. + * Ensure that optional environment variables are present with default values. */ -$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); -$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); -$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; -$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); -$WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; -$WPT_CERTIFICATE_VALIDATION = trim( getenv( 'WPT_CERTIFICATE_VALIDATION' ) ); - -/** - * Determines if the debug mode is enabled based on the 'WPT_DEBUG' environment variable. - * The debug mode can affect error reporting and other debug-related settings. - */ -$WPT_DEBUG_INI = getenv( 'WPT_DEBUG' ); -switch( $WPT_DEBUG_INI ) { - case 0: - case 'false': - $WPT_DEBUG = false; - break; - case 1: - case 'true': - case 'verbose': - $WPT_DEBUG = 'verbose'; - break; - default: - $WPT_DEBUG = false; - break; -} -unset( $WPT_DEBUG_INI ); +$runner_vars = setup_runner_env_vars(); /** * Sets up the SSH private key for use in the test environment if provided. @@ -82,7 +54,7 @@ // If no SSH connection string is provided, add a local operation to the array. // If an SSH connection string is provided, add a remote operation to the array. // Execute the operations defined in the operations array. - if( empty( $WPT_SSH_CONNECT ) ) { + if( empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { perform_operations( array( 'chmod 600 ~/.ssh/id_rsa', 'wp cli info' @@ -90,7 +62,7 @@ } else { perform_operations( array( 'chmod 600 ~/.ssh/id_rsa', - 'ssh -q ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' wp cli info' + 'ssh -q ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' wp cli info' ) ); } @@ -101,7 +73,7 @@ * Useful for local environments */ $certificate_validation = ''; -if( ! $WPT_CERTIFICATE_VALIDATION ) { +if( ! $runner_vars['WPT_CERTIFICATE_VALIDATION'] ) { $certificate_validation .= ' --no-check-certificate'; } @@ -113,14 +85,14 @@ perform_operations( array( // Create the preparation directory if it doesn't exist. The '-p' flag creates intermediate directories as required. - 'mkdir -p ' . escapeshellarg( $WPT_PREPARE_DIR ), + 'mkdir -p ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ), // Clone the WordPress develop repository from GitHub into the preparation directory. // The '--depth=1' flag creates a shallow clone with a history truncated to the last commit. - 'git clone --depth=1 https://github.com/WordPress/wordpress-develop.git ' . escapeshellarg( $WPT_PREPARE_DIR ), + 'git clone --depth=1 https://github.com/WordPress/wordpress-develop.git ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ), // Change directory to the preparation directory, install npm dependencies, and build the project. - 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . '; npm install && npm run build' + 'cd ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . '; npm install && npm run build' ) ); @@ -132,7 +104,7 @@ * This file contains template placeholders that need to be replaced with actual values * from environment variables to configure the WordPress test environment. */ -$contents = file_get_contents( $WPT_PREPARE_DIR . '/wp-tests-config-sample.php' ); +$contents = file_get_contents( $runner_vars['WPT_PREPARE_DIR'] . '/wp-tests-config-sample.php' ); /** * Prepares a script to log system information relevant to the testing environment. @@ -240,7 +212,7 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve $system_logger = $logger_replace_string . $system_logger; // Define a string that will set the 'WP_PHP_BINARY' constant to the path of the PHP executable. -$php_binary_string = 'define( \'WP_PHP_BINARY\', \''. $WPT_PHP_EXECUTABLE . '\' );'; +$php_binary_string = 'define( \'WP_PHP_BINARY\', \''. $runner_vars['WPT_PHP_EXECUTABLE'] . '\' );'; /** * An associative array mapping configuration file placeholders to environment-specific values. @@ -261,22 +233,22 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve $contents = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $contents ); // Write the modified content to the wp-tests-config.php file, which will be used by the test suite. -file_put_contents( $WPT_PREPARE_DIR . '/wp-tests-config.php', $contents ); +file_put_contents( $runner_vars['WPT_PREPARE_DIR'] . '/wp-tests-config.php', $contents ); /** * Determines the PHP version of the test environment to ensure the correct version of PHPUnit is installed. * It constructs a command that prints out the PHP version in a format compatible with PHPUnit's version requirements. */ -$php_version_cmd = $WPT_PHP_EXECUTABLE . " -r \"print PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;\""; +$php_version_cmd = $runner_vars['WPT_PHP_EXECUTABLE'] . " -r \"print PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;\""; /** * If an SSH connection string is provided, the command to determine the PHP version is modified * to execute remotely over SSH. This is required if the test environment is not the local machine. */ -if ( ! empty( $WPT_SSH_CONNECT ) ) { +if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { // The PHP version check command is prefixed with the SSH command, including SSH options, // and the connection string, ensuring the command is executed on the remote machine. - $php_version_cmd = 'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $php_version_cmd ); + $php_version_cmd = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . escapeshellarg( $php_version_cmd ); } // Initialize return value variable for the exec function call. @@ -313,7 +285,7 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve */ // Check if Composer is installed and available in the PATH. -$composer_cmd = 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' && '; +$composer_cmd = 'cd ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . ' && '; $retval = 0; $composer_path = escapeshellarg( system( 'which composer', $retval ) ); @@ -328,7 +300,7 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve log_message( 'Local Composer not found. Downloading latest stable ...' ); perform_operations( array( - 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/composer.phar' ) . ' https://getcomposer.org/composer-stable.phar', + 'wget -O ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] . '/composer.phar' ) . ' https://getcomposer.org/composer-stable.phar', ) ); // Update the command to use the downloaded Composer phar file. @@ -346,12 +318,12 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve * The -r option for rsync enables recursive copying to handle directory structures. * Additional rsync options may be included for more verbose output if debugging is enabled. */ -if ( ! empty( $WPT_SSH_CONNECT ) ) { +if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { // Initialize rsync options with recursive copying. $rsync_options = '-r'; // If debug mode is set to verbose, append 'v' to rsync options for verbose output. - if ( 'verbose' === $WPT_DEBUG ) { + if ( $runner_vars['WPT_DEBUG'] ) { $rsync_options = $rsync_options . 'v'; } @@ -359,7 +331,7 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve // This operation synchronizes the test environment with the prepared files, excluding version control directories // and other non-essential files for test execution. perform_operations( array( - 'rsync ' . $rsync_options . ' --exclude=".git/" --exclude="node_modules/" --exclude="composer.phar" -e "ssh ' . $WPT_SSH_OPTIONS . '" ' . escapeshellarg( trailingslashit( $WPT_PREPARE_DIR ) ) . ' ' . escapeshellarg( $WPT_SSH_CONNECT . ':' . $WPT_TEST_DIR ), + 'rsync ' . $rsync_options . ' --exclude=".git/" --exclude="node_modules/" --exclude="composer.phar" -e "ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . '" ' . escapeshellarg( trailingslashit( $runner_vars['WPT_PREPARE_DIR'] ) ) . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] . ':' . $runner_vars['WPT_TEST_DIR'] ), ) ); } diff --git a/report.php b/report.php index b690f76..1a15d6c 100644 --- a/report.php +++ b/report.php @@ -18,36 +18,9 @@ check_required_env( false ); /** - * Retrieves environment variables and sets defaults for test preparation. - * These variables are used to configure SSH connections, file paths, and - * executable commands needed for setting up the test environment. + * Ensure that optional environment variables are present with default values. */ -$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); -$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); -$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); -$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ); -$WPT_REPORT_API_KEY = trim( getenv( 'WPT_REPORT_API_KEY' ) ); - -/** - * Determines if the debug mode is enabled based on the 'WPT_DEBUG' environment variable. - * The debug mode can affect error reporting and other debug-related settings. - */ -$WPT_DEBUG_INI = getenv( 'WPT_DEBUG' ); -switch( $WPT_DEBUG_INI ) { - case 0: - case 'false': - $WPT_DEBUG = false; - break; - case 1: - case 'true': - case 'verbose': - $WPT_DEBUG = 'verbose'; - break; - default: - $WPT_DEBUG = false; - break; -} -unset( $WPT_DEBUG_INI ); +$runner_vars = setup_runner_env_vars(); /** * Retrieves the SVN revision number from the git repository log. @@ -57,7 +30,7 @@ * and extracts the SVN revision number using a combination of grep and cut commands. */ log_message('Getting SVN Revision'); -$rev = exec('git --git-dir=' . escapeshellarg( $WPT_PREPARE_DIR ) . '/.git log -1 --pretty=%B | grep "git-svn-id:" | cut -d " " -f 2 | cut -d "@" -f 2'); +$rev = exec('git --git-dir=' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . '/.git log -1 --pretty=%B | grep "git-svn-id:" | cut -d " " -f 2 | cut -d "@" -f 2'); /** * Retrieves the latest SVN commit message from the git repository log. @@ -66,7 +39,7 @@ * fetches the latest commit message, and trims any whitespace from the message. */ log_message('Getting SVN message'); -$message = trim( exec('git --git-dir=' . escapeshellarg( $WPT_PREPARE_DIR ) . '/.git log -1 --pretty=%B | head -1') ); +$message = trim( exec('git --git-dir=' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . '/.git log -1 --pretty=%B | head -1') ); /** * Prepares the file path for copying the junit.xml results. @@ -76,7 +49,7 @@ * safely used in shell commands. */ log_message('Copying junit.xml results'); -$junit_location = escapeshellarg( $WPT_TEST_DIR ) . '/tests/phpunit/build/logs/*'; +$junit_location = escapeshellarg( $runner_vars['WPT_TEST_DIR'] ) . '/tests/phpunit/build/logs/*'; /** * Modifies the junit.xml results file path for a remote location if an SSH connection is available. @@ -85,8 +58,8 @@ * command and options for accessing the remote file system. It concatenates SSH options with the * remote path to ensure that the junit.xml results can be accessed or copied over SSH. */ -if ( ! empty( $WPT_SSH_CONNECT ) ) { - $junit_location = '-e "ssh ' . $WPT_SSH_OPTIONS . '" ' . escapeshellarg( $WPT_SSH_CONNECT . ':' . $junit_location ); +if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { + $junit_location = '-e "ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . '" ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] . ':' . $junit_location ); } /** @@ -97,7 +70,7 @@ */ $rsync_options = '-r'; -if ( 'verbose' === $WPT_DEBUG ) { +if ( $runner_vars['WPT_DEBUG'] ) { $rsync_options = $rsync_options . 'v'; } @@ -108,7 +81,7 @@ * then passed to the `perform_operations` function, which executes the command to synchronize * the junit.xml files from the source to the destination directory. */ -$junit_exec = 'rsync ' . $rsync_options . ' ' . $junit_location . ' ' . escapeshellarg( $WPT_PREPARE_DIR ); +$junit_exec = 'rsync ' . $rsync_options . ' ' . $junit_location . ' ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ); perform_operations( array( $junit_exec, ) ); @@ -121,7 +94,7 @@ * it for upload or to extract relevant test run information. */ log_message( 'Processing and uploading junit.xml' ); -$xml = file_get_contents( $WPT_PREPARE_DIR . '/junit.xml' ); +$xml = file_get_contents( $runner_vars['WPT_PREPARE_DIR'] . '/junit.xml' ); $results = process_junit_xml( $xml ); /** @@ -132,9 +105,9 @@ * are generated by calling a function that retrieves these details, then encoded into JSON format. */ $env = ''; -if ( file_exists( $WPT_PREPARE_DIR . '/env.json' ) ) { - $env = file_get_contents( $WPT_PREPARE_DIR . '/env.json' ); -} elseif ( $WPT_PREPARE_DIR === $WPT_TEST_DIR ) { +if ( file_exists( $runner_vars['WPT_PREPARE_DIR'] . '/env.json' ) ) { + $env = file_get_contents( $runner_vars['WPT_PREPARE_DIR'] . '/env.json' ); +} elseif ( $runner_vars['WPT_PREPARE_DIR'] === $runner_vars['WPT_TEST_DIR'] ) { $env = json_encode( get_env_details(), JSON_PRETTY_PRINT ); } @@ -146,10 +119,10 @@ * message is logged along with the HTTP status. If no API key is provided, it logs the test results * and environment details locally. */ -if( ! empty( $WPT_REPORT_API_KEY ) ) { +if( ! empty( $runner_vars['WPT_REPORT_API_KEY'] ) ) { // Upload the results and capture the HTTP status and response body - list( $http_status, $response_body ) = upload_results( $results, $rev, $message, $env, $WPT_REPORT_API_KEY ); + list( $http_status, $response_body ) = upload_results( $results, $rev, $message, $env, $runner_vars['WPT_REPORT_API_KEY'] ); // Decode the JSON response body $response = json_decode( $response_body, true ); diff --git a/test.php b/test.php index 18b3f4f..c2b56c7 100644 --- a/test.php +++ b/test.php @@ -17,14 +17,9 @@ check_required_env(); /** - * Retrieves environment variables and sets defaults for test preparation. - * These variables are used to configure SSH connections, file paths, and - * executable commands needed for setting up the test environment. + * Ensure that all environment variables are present with default values. */ -$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); -$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); -$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; -$WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; +$runner_vars = setup_runner_env_vars(); // Uses the flavor (usually to test WordPress Multisite) $WPT_FLAVOR_INI = trim( getenv( 'WPT_FLAVOR' ) ); @@ -71,12 +66,12 @@ */ $WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ); if( empty( $WPT_PHPUNIT_CMD ) ) { - $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT; + $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $runner_vars['WPT_TEST_DIR'] ) . ' && ' . $runner_vars['WPT_PHP_EXECUTABLE'] . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT; } // If an SSH connection string is provided, prepend the SSH command to the PHPUnit execution command. -if ( ! empty( $WPT_SSH_CONNECT ) ) { - $WPT_PHPUNIT_CMD = 'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $WPT_PHPUNIT_CMD ); +if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) { + $WPT_PHPUNIT_CMD = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . escapeshellarg( $WPT_PHPUNIT_CMD ); } // Execute the PHPUnit command.