WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#30336 closed defect (bug) (fixed)

microtime returning a string causes false test failures

Reported by: jorbin Owned by: jorbin
Milestone: 4.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:
PR Number:

Description

One of the assertions inside test_get_pages_cache (and possibly elsewhere) is that when deleting a post, the last_changed time in the posts cache is greater then it was before deleting it. The problem is that we are comparing microtime strings.

So you end up with things like:

Failed asserting that '0.01805200 1415892888' is greater than '0.99591600 1415892887'.

The problem is that it should be comparing 1415892888.018052 and 1415892887.995916 which would cause the test to pass.

Change History (2)

#1 @jorbin
5 years ago

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

In 30337:

When asserting microtime output as a number, make it a number

microtime is by default a string. Doing a greater then or less than check of that string is a bad idea since it uses the first part (the micro part of microtime) rather then the actual time. This adds a helper to convert microtime output into a float which we can then use to properly compare the output of microtime.

This fixes an intermittent test failure.

fixes #30336

#2 @johnbillion
3 years ago

In 40566:

When asserting microtime output as a number, make it a number

microtime is by default a string. Doing a greater then or less than check of that string is a bad idea since it uses the first part (the micro part of microtime) rather then the actual time. This adds a helper to convert microtime output into a float which we can then use to properly compare the output of microtime.

This fixes an intermittent test failure.

See #30336

Merges [30337] to the 4.0 branch.

Note: See TracTickets for help on using tickets.