WordPress.org

Make WordPress Core

#49663 closed defect (bug) (fixed)

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

Reported by: azaozz Owned by: 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 10 months ago.
49663.1.diff (1.3 KB) - added by azaozz 10 months ago.

Download all attachments as: .zip

Change History (8)

#1 @azaozz
10 months 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
10 months ago

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

@azaozz
10 months ago

#3 @azaozz
10 months 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
10 months ago

#4 @azaozz
10 months 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
10 months 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
10 months 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.