Make WordPress Core

Opened 5 years ago

Last modified 8 months ago

#37371 accepted enhancement

Reduce reliance on randomness in tests

Reported by: johnbillion Owned by: johnbillion
Milestone: Future Release Priority: lowest
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch good-first-bug
Focuses: Cc:


39 of core's tests rely on rand_str() returning a different value each time it's called in order to pass. It's entirely possible that rand_str() could return an identical value twice, and therefore the test would randomly (ho ho) fail.

Let's remove all the unnecessary uses of rand_str(), where a fixed string would suffice. This will also shave off some milliseconds.

Attachments (1)

37371.patch (17.4 KB) - added by johnbillion 5 years ago.

Download all attachments as: .zip

Change History (16)

5 years ago

#1 @johnbillion
5 years ago

  • Keywords has-patch added; needs-patch removed

37371.patch replaces all instances of rand_str() with static strings where the test will fail if rand_str() were to return sequential identical strings.

#2 @johnbillion
5 years ago

  • Milestone changed from Future Release to 4.7

#3 @johnbillion
5 years ago

In 38382:

Build/Test Tools: Remove many unnecessary calls to rand_str() which can, in theory, fail at random. Static strings are much more appropriate.

See #37371

#4 @jorbin
5 years ago

@johnbillion Do you want to remove the rest of the calls to rand_strl? If so, good first bug?

#5 @johnbillion
5 years ago

  • Keywords needs-patch good-first-bug added; has-patch removed
  • Milestone changed from 4.7 to Future Release

#6 @johnbillion
5 years ago

  • Keywords good-first-bug removed
  • Owner set to johnbillion
  • Status changed from new to accepted
  • Summary changed from Reduce reliance on rand_str() in tests to Reduce reliance on randomness in tests

There's also a bunch of instances of rand() in tests which are just as unnecessary.

#7 @johnbillion
5 years ago

In 38762:

Build/Test Tools: Begin eliminating unnecessary randomness in tests.

Although unlikely, clashes in randomly generated strings could cause unexpected failures. In addition, most randomness is entirely unnecessary, is bad practice, and increases test time (however small it may be).

See #37371

#8 @johnbillion
5 years ago

In 38763:

Build/Test Tools: Continue eliminating randomness in tests.

See [38762]
See #37371

#9 @johnbillion
5 years ago

In 38938:

Build/Test Tools: Continue eliminating randomness in tests.

See #37371

#10 @johnbillion
4 years ago

In 39556:

Build/Test Tools: Remove some more randomness.

See #37371

#11 @desrosj
19 months ago

  • Keywords reporter-feedback added

@johnbillion is there any more work to be done here? Can we wrap this up during 5.4?

#12 @johnbillion
19 months ago

  • Keywords reporter-feedback removed
  • Milestone changed from Future Release to 5.4
  • Priority changed from normal to low

#13 @davidbaumwald
15 months ago

@johnbillion Is this still on your plate for 5.4?

#14 @johnbillion
15 months ago

  • Milestone changed from 5.4 to Future Release
  • Priority changed from low to lowest

#15 @johnbillion
8 months ago

  • Keywords good-first-bug added
Note: See TracTickets for help on using tickets.