In DrupalWebTestCase, drupalGetTestFiles() uses drupalCompareFiles() as callback for usort(). drupalCompareFiles($file1, $file2) does not follow the contract for sort callback functions in that drupalCompareFiles($file1, $file2) may return 1 to indicate that $file1 > $file2, while drupalCompareFiles($file2, $file1) also returns 1 for the same two files, indicating that $file2 > $file1.

Example:
$file1->name = 'foo-2.txt'; filesize($file1->filepath) = 10;
$file2->name = 'foo-1.txt'; filesize($file2->filepath) = 20;

This makes the sorted array depend on the initial sorting of the files, and that is not necessarily the same across systems. file_scan_directory() just returns the files in the order they are returned by the underlying filesystem (this was the reason for some confusing testbot results in #255551: DX: Array-itize file_scan_directory()'s parameters).

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

c960657’s picture

Status: Needs work » Needs review
StatusFileSize
new2.39 KB

Hmm, apparently one test was relying on the old sort order. I've added the fix suggested by drewish in #389040: fix bug in UserPictureTestCase::testWithGDinvalidSize.

dries’s picture

Status: Needs review » Needs work

The code comment // Return TRUE if $file1 is larger than $file2. needs to be updated now...

c960657’s picture

Status: Needs work » Needs review
StatusFileSize
new2.74 KB

Fixed. I also reverted the order of the if/else parts, so the most important aspect, size, comes before the alphabetical comparison.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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