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).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | simpletest-sort-3.patch | 2.74 KB | c960657 |
| #2 | simpletest-sort-2.patch | 2.39 KB | c960657 |
| simpletest-sort-1.patch | 1.13 KB | c960657 |
Comments
Comment #2
c960657 commentedHmm, 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.
Comment #3
dries commentedThe code comment
// Return TRUE if $file1 is larger than $file2.needs to be updated now...Comment #4
c960657 commentedFixed. I also reverted the order of the if/else parts, so the most important aspect, size, comes before the alphabetical comparison.
Comment #5
dries commentedCommitted to CVS HEAD. Thanks.