WordPress.org

Make WordPress Core

Opened 16 months ago

Closed 4 months ago

#40071 closed defect (bug) (fixed)

Relative path used in test suite forces tests to be ran from tests dir

Reported by: PressLabs Owned by: adamsilverstein
Milestone: 5.0 Priority: low
Severity: normal Version: 4.7.3
Component: Build/Test Tools Keywords: has-patch commit
Focuses: Cc:

Description

In the wordPress test suite for version 4.7.3, inside tests/phpunit/tests/rest-api/rest-schema-setup.php line 303 a relative path is used for writing into a file. Our use case is that the WordPress tests are cloned into our project and they run alongside our own test suite from an upper level directory in an automated build. That makes this specific test to fail since it cannot resolve the relative path correctly and thus the whole build fails.

The suggestion would be to use absolute paths here in order to let others include this test suite as a subset of a bigger test suite and run all of them from top level, without cd-ing into every subset.

Attachments (1)

40071.diff (1.2 KB) - added by johnbillion 16 months ago.

Download all attachments as: .zip

Change History (8)

@johnbillion
16 months ago

#1 @johnbillion
16 months ago

  • Keywords has-patch reporter-feedback needs-testing added
  • Priority changed from normal to low

Thanks for the report @PressLabs. Could you give 40071.diff a test and see if it addresses the issue for you?

Introduced in [40058].

#2 follow-up: @johnbillion
16 months ago

cc @adamsilverstein for sanity check.

#3 in reply to: ↑ 2 @adamsilverstein
16 months ago

Replying to johnbillion:

cc @adamsilverstein for sanity check.

@johnbillion Looks good. I tested this out and verified the fixture file is generated in the correct location when I run phpunit from the root.

Last edited 16 months ago by adamsilverstein (previous) (diff)

#4 @adamsilverstein
16 months ago

  • Owner set to adamsilverstein
  • Status changed from new to accepted

#5 @PressLabs
16 months ago

I confirm that the fix works.

#6 @adamsilverstein
4 months ago

  • Keywords commit added; reporter-feedback needs-testing removed
  • Milestone changed from Awaiting Review to 5.0

#7 @adamsilverstein
4 months ago

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

In 42741:

Unit Tests: add a DIR_TESTROOT constant to avoid relative paths.

Fix an issue that prevents tests from running correctly when run outside their normal context.

Props PressLabs, johnbillion.
Fixes #40071.

Note: See TracTickets for help on using tickets.