Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
- Maintainers and developers are confused about varying positive test assertion counts for patches passing tests.
Goal
- Ensure that assertion counts can be trusted.
Details
- Running the same test suite on the same machine can yield a difference of hundreds assertions.
- The difference is caused by various tests that use
rand(1, 10)
for their initial setup (which means that test assertions are exponentially increasing for each additional item).
Solution
- Remove all calls to
rand()
from all tests.
Comment | File | Size | Author |
---|---|---|---|
#11 | d7-1560028.diff | 2.03 KB | thehong |
#9 | drupal8.tests-rand.9.patch | 1.91 KB | sun |
#4 | 1560028.patch | 1.82 KB | bleen |
#1 | 1560028.patch | 1.82 KB | bleen |
Comments
Comment #1
bleen CreditAttribution: bleen commentedIncidentally, we should not remove *all* calls to rand() (or mt_rand()) from simpletests as most of them are used to set a random weight, languagecode, chr, etc... We only need to remove those calls that case an inconsistent number of assertions.
In fact, I only found three places where rand() is used in such a way that there are random assertions.
Comment #2
sunAwesome, thanks!
Comment #4
bleen CreditAttribution: bleen commentedthis should fix that errr
Comment #5
bleen CreditAttribution: bleen commentedhere testbot .. here boy
Comment #6
sunComment #7
sun#4: 1560028.patch queued for re-testing.
Comment #9
sunComment #10
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks!
Comment #11
thehong CreditAttribution: thehong commentedComment #12
sunThanks @thehong! :)
Comment #13
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/e0961c9