Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#49663 closed defect (bug) (fixed)

Fix PHPUnit bootstrap to install from the same directory where the tests will be run

Reported by: azaozz's profile azaozz Owned by: azaozz's profile azaozz
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.1
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

After #44492 and #45863 when running npm run test or the equivalent grunt build followed by phpunit, WP is build to /build but /tests/phpunit/includes/install.php runs in /src.

This triggers missing files errors if WordPress hasn't been built to /src before.

Attachments (2)

49663.diff (1.5 KB) - added by azaozz 5 years ago.
49663.1.diff (1.3 KB) - added by azaozz 5 years ago.

Download all attachments as: .zip

Change History (8)

#1 @azaozz
5 years ago

Happens because WP_RUN_CORE_TESTS is not defined when PHP is run from the cli: https://core.trac.wordpress.org/browser/tags/5.3.2/tests/phpunit/includes/bootstrap.php#L100.

Seems a simple fix would be to pass another param to system( php ... ) similarly to $config_file_path and $multisite.

#2 @azaozz
5 years ago

Related: #48154. This is the reason for all the missing files when testing.

@azaozz
5 years ago

#3 @azaozz
5 years ago

  • Keywords has-patch needs-testing added

In 49663.diff: pass the WP_RUN_CORE_TESTS constant when running /tests/phpunit/includes/install.php from cli.

@azaozz
5 years ago

#4 @azaozz
5 years ago

In 49663.1.diff: same as 49663.diff but instead of passing vars through cli uses putenv() and getenv(). These were pretty much meant for cases like this.

#5 @azaozz
5 years ago

  • Keywords needs-testing removed

Looking again, perhaps better to not rely on putenv() and getenv(). The former might be disabled and the latter might behave strangely in some specific conditions. 49663.diff is probably a better idea.

#6 @azaozz
5 years ago

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

In 47496:

Build/Test Tools: Fix PHPUnit bootstrap to install WP from /build when tests are run with npm run test, grunt test, grunt then phpunit, etc.

Fixes #49663.

Note: See TracTickets for help on using tickets.