Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#51735 new defect (bug)

Increase the reliability of backing up the mu-plugins directory during tests

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:


In order to facilitate switching back to using src as the default directory for testing (#51734) we need to be sure that there's no chance of local files being deleted during a test run.

The tests in tests/phpunit/tests/admin/includesPlugin.php perform a potentially dangerous operation. They back up the mu-plugins directory but then perform assertions before restoring the backup. If an assertion fails, you can lose your mu-plugins directory.

To increase the reliability of these tests:

  1. The backup and restore should only happen once, during wpSetUpBeforeClass() and wpTearDownAfterClass()
  2. The backup and restore should just rename the directory to save a bunch of file iteration and writing.
  3. The assertions should be moved to the end of each test so any test-specific cleanup always runs.

Change History (1)

This ticket was mentioned in PR #714 on WordPress/wordpress-develop by johnbillion.

2 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed
Note: See TracTickets for help on using tickets.