Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export WPT_TEST_DIR=wp-test-runner-$TRAVIS_BUILD_NUMBER
export WPT_TABLE_PREFIX=wptests_$TRAVIS_BUILD_NUMBER\_
```

The test suite's temporary files are kept in a `wp-temp` directory inside the test directory, so runs with their own `WPT_TEST_DIR` do not share the system temp directory.

Connect to a remote environment over SSH by having the CI job provision the SSH key:

```bash
Expand Down Expand Up @@ -272,7 +274,7 @@ export WPT_PREPARE_DIR="/tmp/wp-test-runner"

**Test directory**

Path to the directory where the WordPress develop checkout can be placed and tests can be run. When running tests in the same environment, set WPT_TEST_DIR to WPT_PREPARE_DIR equally.
Path to the directory where the WordPress develop checkout can be placed and tests can be run. When running tests in the same environment, set WPT_TEST_DIR to WPT_PREPARE_DIR equally. The test suite's temporary files are kept in a `wp-temp` directory inside this path.


```
Expand Down
28 changes: 28 additions & 0 deletions prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,34 @@ function curl_selected_bits(\$k) { return in_array(\$k, array('version', 'ssl_ve
// Replace the placeholders in the wp-tests-config-sample.php file content with actual values.
$contents = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $contents );

/*
* Point the test suite's temporary directory inside the test directory, so
* concurrent runs with their own WPT_TEST_DIR do not share the system temp
* directory. Core's get_temp_dir() checks the WP_TEMP_DIR constant first,
* and several tests write fixed file names into that directory, so two runs
* sharing it can delete or overwrite each other's files mid test.
*
* The path is anchored to the config file's own location, so it stays
* correct after the config is copied to a remote test environment, and the
* directory is removed together with the test directory during cleanup.
*/
$contents .= <<<'WPT_TEMP_DIR_CONFIG'

if ( ! defined( 'WP_TEMP_DIR' ) ) {
define( 'WP_TEMP_DIR', __DIR__ . '/wp-temp/' );
}

if ( ! is_dir( WP_TEMP_DIR ) ) {
mkdir( WP_TEMP_DIR, 0777, true );
}

if ( ! is_dir( WP_TEMP_DIR ) || ! is_writable( WP_TEMP_DIR ) ) {
echo 'The temporary directory ' . WP_TEMP_DIR . ' could not be created or is not writable. Fix the permissions on the test directory and run again.' . PHP_EOL;
exit( 1 );
}

WPT_TEMP_DIR_CONFIG;

// Write the modified content to the wp-tests-config.php file, which will be used by the test suite.
file_put_contents( $runner_vars['WPT_PREPARE_DIR'] . '/wp-tests-config.php', $contents );

Expand Down
Loading