Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@
* safely used in shell commands.
*/
log_message('Copying junit.xml results');
$junit_location = $runner_vars['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.
* If the WPT_SSH_CONNECT environment variable is not empty, indicating that an SSH connection
* is configured, this snippet adapts the junit_location variable to include the necessary SSH
* 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 ' . $runner_vars['WPT_SSH_OPTIONS'] . '" ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ':' . escapeshellarg( $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 );
}

/**
Expand Down
8 changes: 3 additions & 5 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@
* avoid reporting useless tests.
*/
$WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) );
if ( empty( $WPT_PHPUNIT_CMD ) ) {
$WPT_PHPUNIT_CMD = escapeshellarg( 'cd ' . $runner_vars['WPT_TEST_DIR'] . ' && ' . $runner_vars['WPT_PHP_EXECUTABLE'] . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT );
} else {
$WPT_PHPUNIT_CMD = escapeshellarg( $WPT_PHPUNIT_CMD );
if( empty( $WPT_PHPUNIT_CMD ) ) {
$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( $runner_vars['WPT_SSH_CONNECT'] ) ) {
$WPT_PHPUNIT_CMD = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . $WPT_PHPUNIT_CMD;
$WPT_PHPUNIT_CMD = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . escapeshellarg( $WPT_PHPUNIT_CMD );
}

// Execute the PHPUnit command.
Expand Down