Download & Extend

Remove all calls to rand() from tests

Project:Drupal core
Version:7.x-dev
Component:simpletest.module
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:Testing system

Issue Summary

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.

Comments

#1

Status:active» needs review

Incidentally, 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.

AttachmentSizeStatusTest resultOperations
1560028.patch1.82 KBIdleFAILED: [[SimpleTest]]: [MySQL] 36,670 pass(es), 9 fail(s), and 9 exception(s).View details

#2

Component:other» simpletest.module
Status:needs review» reviewed & tested by the community

Awesome, thanks!

#3

Status:reviewed & tested by the community» needs work

The last submitted patch, 1560028.patch, failed testing.

#4

this should fix that errr

AttachmentSizeStatusTest resultOperations
1560028.patch1.82 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1560028_0.patch. Unable to apply patch. See the log in the details link for more information.View details

#5

Status:needs work» needs review

here testbot .. here boy

#6

Status:needs review» reviewed & tested by the community

#7

#4: 1560028.patch queued for re-testing.

#8

Status:reviewed & tested by the community» needs work

The last submitted patch, 1560028.patch, failed testing.

#9

Status:needs work» reviewed & tested by the community
AttachmentSizeStatusTest resultOperations
drupal8.tests-rand.9.patch1.91 KBIdlePASSED: [[SimpleTest]]: [MySQL] 37,043 pass(es).View details

#10

Version:8.x-dev» 7.x-dev
Status:reviewed & tested by the community» patch (to be ported)

Committed to 8.x. Thanks!

#11

Status:patch (to be ported)» needs review
AttachmentSizeStatusTest resultOperations
d7-1560028.diff2.03 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,240 pass(es).View details

#12

Status:needs review» reviewed & tested by the community

Thanks @thehong! :)

#13

Status:reviewed & tested by the community» fixed

Committed to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/e0961c9

#14

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here