[wp-trac] [WordPress Trac] #40910: Limit writable directories required by WordPress unit test suite

WordPress Trac noreply at wordpress.org
Fri Jun 2 16:21:07 UTC 2017


#40910: Limit writable directories required by WordPress unit test suite
------------------------------+-----------------------------
 Reporter:  danielbachhuber   |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 Some environments only permit writing to specific directories. But, the
 WordPress test suite currently assumes it can write to a variety of
 directories.

 Based on searches for `file_put_contents()`, `copy()`, and `symlink()`,
 here are the directories I found:

 * `tests/phpunit/data`
         * `.trac-ticket-cache.*` is created to store a cache of Trac
 ticket numbers.
 * `tests/phpunit/build/logs/`
         * `junit.xml` is created with the results of the test run.
 * `tests/qunit/fixtures`
         * `wp-api-generated.js` is generated by PHPUnit  for use in QUnit
 tests.
 * `/tmp/`
         * Variety of files are copied out of `phpunit/data` into `/tmp/`
 for test-specific transformation.
 * `wp-content/themes`
         * `theme-file-parent` and `theme-file-child` are symlinked from
 the PHPUnit data directory into the theme directory
 * `wp-content/uploads`
         * Attachments are copied

 Generally, in write-restricted environments, the test suite fails when it
 tries to write to directories it doesn't have access to. More directories
 could be found by running the test suite against a write-restricted
 environment.

 To better ensure WordPress compatibility with a variety of platforms, we
 should ensure these file write requirements are compatible with limited
 write directories. Here are some strategies we can use:

 * Properly use `wp_tempnam()` instead of hardcoding `/tmp/` paths.
 * Permit some write directories to be configurable with a constant or
 environment variable.
 * Failing gracefully, in certain cases, when a file can't be written.

 cc @mikeschroder @octalmage

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40910>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list