Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#44605 closed defect (bug) (duplicate)

unit tests that create tmp files should use sys_get_temp_dir() instead of hardcoding /tmp/

Reported by: pbiron's profile pbiron Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

A few of the existing unit tests contain the equivalent of:

copy( DIR_TESTDATA . '/images/foo.jpg', '/tmp/foo.jpg' );

Folks running the tests on Windows need to create C:\tmp for those tests to succeed.

Instead, unit tests should use the equivalent of:

copy( DIR_TESTDATA . '/images/foo.jpg', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'foo.jpg' );

Attachments (1)

44605.diff (4.3 KB) - added by pbiron 6 years ago.

Download all attachments as: .zip

Change History (4)

@pbiron
6 years ago

#1 @pbiron
6 years ago

44605.diff fixes all existing tests.

There are a few other occurrences of /tmp in the existing tests, but to the best of my knowledge those other uses don't actually try to create temp files in `/tmp'.

I would appreciate someone testing the patch on a non-Windows box to make sure the affected tests still succeed.

Last edited 6 years ago by pbiron (previous) (diff)

#2 follow-up: @birgire
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Good catches @pbiron but it looks like this belongs to #39975

Maybe you could refresh the latest patch over there if needed?

#3 in reply to: ↑ 2 @pbiron
6 years ago

Replying to birgire:

Good catches @pbiron but it looks like this belongs to #39975

Maybe you could refresh the latest patch over there if needed?

All the cases my patch fixes are also fixed in the latest patch on #39975.

Note: See TracTickets for help on using tickets.