#37371 closed task (blessed) (fixed)
Reduce reliance on randomness in tests for 5.9
| Reported by: | johnbillion | Owned by: | johnbillion |
|---|---|---|---|
| Priority: | lowest | Milestone: | 5.9 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
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 (2)
Change History (23)
#4
@
10 years ago
@johnbillion Do you want to remove the rest of the calls to rand_strl? If so, good first bug?
#5
@
10 years ago
- Keywords needs-patch good-first-bug added; has-patch removed
- Milestone 4.7 → Future Release
#6
@
10 years ago
- Keywords good-first-bug removed
- Owner set to
- Status new → accepted
- Summary Reduce reliance on rand_str() in tests → Reduce reliance on randomness in tests
There's also a bunch of instances of rand() in tests which are just as unnecessary.
#11
@
7 years ago
- Keywords reporter-feedback added
@johnbillion is there any more work to be done here? Can we wrap this up during 5.4?
#12
@
7 years ago
- Keywords reporter-feedback removed
- Milestone Future Release → 5.4
- Priority normal → low
@
5 years ago
Replace other rand_str() and rand() calls with static string to eliminate unnecessary randomness in tests. This is my first patch.
#17
@
5 years ago
- Keywords good-first-bug removed
- Milestone Future Release → 5.9
- Summary Reduce reliance on randomness in tests → Reduce reliance on randomness in tests for 5.9
- Type enhancement → task (blessed)
I'm moving this into 5.9 to get the patch from @johnillo reviewed and committed before it goes too stale. This ticket can then be closed and any remaining unnecessary randomness can be addressed in follow-up tickets.
This ticket was mentioned in PR #2023 on WordPress/wordpress-develop by johnbillion.
5 years ago
#18
- Keywords has-unit-tests added
Patch from johnillo. Opening a PR so we can verify that the tests pass.
Trac ticket: https://core.trac.wordpress.org/ticket/37371
37371.patch replaces all instances of
rand_str()with static strings where the test will fail ifrand_str()were to return sequential identical strings.