Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#51735 closed defect (bug) (fixed)

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

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

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.


6 years ago
#1

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

#2 @johnbillion
6 years ago

  • Milestone Awaiting ReviewFuture Release

#3 @johnbillion
6 years ago

  • Milestone Future Release5.8

#4 @johnbillion
6 years ago

  • Owner set to johnbillion
  • Resolutionfixed
  • Status newclosed

In 50443:

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

Fixes #51735

#6 @johnbillion
6 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closedreopened

#7 @desrosj
6 years ago

  • Keywords commit dev-reviewed added; fixed-major removed
  • Milestone 5.85.7

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

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


6 years ago

#9 @johnbillion
6 years ago

  • Resolutionfixed
  • Status reopenedclosed

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.