Page MenuHomePhabricator

ReleaseNotesTest:testReleaseNotesFilesExistAndAreNotMalformed takes ~ 4 seconds
Closed, ResolvedPublic

Description

The test ReleaseNotesTest:testReleaseNotesFilesExistAndAreNotMalformed takes 4 seconds on my machine. Most notably it invokes mb_strlen and assertLessThanOrEqual on each line of some files at the root of the repository. HISTORY has 20000 lines and thus that is rather slow:

You should really fix these slow tests (>50ms)...
 1. 3217ms to run ReleaseNotesTest:testReleaseNotesFilesExistAndAreNotMalformed
...

The test should be refactored to do less invocations of assertLessThanOrEqual. For example by keeping track of lines being too long in an array an asserting the array is empty.

tests/phpunit/documentation/ReleaseNotesTest.php
53     private function assertFileLength( $type, $fileName ) {
54         $file = file( $fileName, FILE_IGNORE_NEW_LINES ); 

60 
61         foreach ( $file as $i => $line ) {
62             $num = $i + 1;
63             $this->assertLessThanOrEqual(
64                 // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
65                 80,
66                 mb_strlen( $line ),
67                 "$type file '$fileName' line $num, is longer than 80 chars:\n\t'$line'"
68             );
69         }
70     }
71 }

Event Timeline

hashar created this task.Jul 2 2019, 9:32 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 2 2019, 9:32 AM
hashar claimed this task.Jul 2 2019, 10:13 AM
hashar triaged this task as Normal priority.

Change 520205 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@master] test: refactor/speed up release note file test

https://gerrit.wikimedia.org/r/520205

Change 520205 merged by jenkins-bot:
[mediawiki/core@master] test: refactor/speed up release note file test

https://gerrit.wikimedia.org/r/520205

Change 520464 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@REL1_33] test: refactor/speed up release note file test

https://gerrit.wikimedia.org/r/520464

hashar added a comment.Jul 3 2019, 3:34 PM

Verified to be working. Backport to REL1_33 is straightforward, the one for REL1_32 is not so I have skip that branch.

Reedy added a comment.Jul 3 2019, 3:46 PM

Verified to be working. Backport to REL1_33 is straightforward, the one for REL1_32 is not so I have skip that branch.

If you're backporting... Just copy the whole file over. Or backport a few extra supporting commits :)

Change 520464 merged by jenkins-bot:
[mediawiki/core@REL1_33] test: refactor/speed up release note file test

https://gerrit.wikimedia.org/r/520464

hashar closed this task as Resolved.Jul 18 2019, 1:08 PM

Too many changes to backport for REL1_32 or REL1_31 so I just skip those. It is not a huge win anyway :-]