WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 7 months ago

#51735 closed defect (bug) (fixed)

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

Reported by: johnbillion Owned by: johnbillion
Milestone: 5.7 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests commit dev-reviewed
Focuses: Cc:

Description

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 (9)

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


10 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

#2 @johnbillion
7 months ago

  • Milestone changed from Awaiting Review to Future Release

#3 @johnbillion
7 months ago

  • Milestone changed from Future Release to 5.8

#4 @johnbillion
7 months ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 50443:

Build/Test Tools: Increase the reliability of backing up the mu-plugins directory during tests.

Fixes #51735

#6 @johnbillion
7 months ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#7 @desrosj
7 months ago

  • Keywords commit dev-reviewed added; fixed-major removed
  • Milestone changed from 5.8 to 5.7

Let's include this with the [50441-50442] backports.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


7 months ago

#9 @johnbillion
7 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 50464:

Build/Test Tools: PHPUnit test improvements:

  • Switch back to running the PHPUnit test suite against the src directory instead of build
  • Increase the reliability of backing up the mu-plugins directory during tests
  • Split the PHPUnit tests for PHP versions below 7.0 in half, allowing them to run in parallel and reduce the overall test run duration on GitHub Actions

Merges [50441-50444] to the 5.7 branch.

Fixes #51734, #51735, #52645

Note: See TracTickets for help on using tickets.