Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#60288 closed defect (bug) (fixed)

Fix unstable query test for post tags

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The Tests_Query_Results::test_query_tag__not_in() test is unstable and thus may occasionally fail, entirely random, see for example https://github.com/WordPress/wordpress-develop/actions/runs/7573278489/job/20625142895?pr=5658.

This is because two of the posts that are generated have the exact same date and time and thus their order in the query result is random.

For the same reason, the other test methods test_query_paged() and test_query_paged_and_posts_per_page() in the same class are unstable as well.

An easy fix for this is to use unique dates.

It looks like this goes back to the almost 10 year old commit [30276]. :)

Change History (4)

This ticket was mentioned in PR #5899 on WordPress/wordpress-develop by @flixos90.


6 months ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch removed

This PR ensures the post dates are distinct, to avoid randomness in the results order.

With this, the many-trackbacks and no-comments test posts no longer use the same date.

Trac ticket: https://core.trac.wordpress.org/ticket/60288

@boonebgorges commented on PR #5899:


6 months ago
#2

Change looks good to me. Sorry for the trouble :-D

@flixos90 commented on PR #5899:


6 months ago
#3

Committed in https://core.trac.wordpress.org/changeset/57308 - for some reason not properly showing up in SVN yet.

#4 @flixos90
6 months ago

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

Fixed via [57308] (somehow not showing in SVN, but it's there).

Note: See TracTickets for help on using tickets.