Page MenuHomePhabricator

MSCompoundFileReaderTest fails on macOS
Closed, ResolvedPublic

Description

On master branch of MediaWiki, MSCompoundFileReaderTest is failing when executed on macOS:

$ php tests/phpunit/phpunit.php --filter MSCompoundFileReaderTest
Using PHP 7.3.5
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

FFFFFFF...                                                        10 / 10 (100%)

Time: 6.67 seconds, Memory: 257.00MB

There were 7 failures:

1) MSCompoundFileReaderTest::testReadFile with data set #0 ('calc.xls', 'application/vnd.ms-excel')
Failed asserting that null is identical to 'application/vnd.ms-excel'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

2) MSCompoundFileReaderTest::testReadFile with data set #1 ('excel2016-compat97.xls', 'application/vnd.ms-excel')
Failed asserting that null is identical to 'application/vnd.ms-excel'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

3) MSCompoundFileReaderTest::testReadFile with data set #2 ('gnumeric.xls', 'application/vnd.ms-excel')
Failed asserting that null is identical to 'application/vnd.ms-excel'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

4) MSCompoundFileReaderTest::testReadFile with data set #3 ('impress.ppt', 'application/vnd.ms-powerpoint')
Failed asserting that null is identical to 'application/vnd.ms-powerpoint'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

5) MSCompoundFileReaderTest::testReadFile with data set #4 ('powerpoint2016-compat97.ppt', 'application/vnd.ms-powerpoint')
Failed asserting that null is identical to 'application/vnd.ms-powerpoint'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

6) MSCompoundFileReaderTest::testReadFile with data set #5 ('word2016-compat97.doc', 'application/msword')
Failed asserting that null is identical to 'application/msword'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

7) MSCompoundFileReaderTest::testReadFile with data set #6 ('writer.doc', 'application/msword')
Failed asserting that null is identical to 'application/msword'.

/Users/mateszabo/Wikia/mediawiki/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php:40
/Users/mateszabo/Wikia/mediawiki/maintenance/doMaintenance.php:99

FAILURES!
Tests: 10, Assertions: 20, Failures: 7.

The test passes when run in a Linux VM or the WM CI environment. The test or the underlying class should be fixed so that it consistently passes on all environments.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Adding @tstarling as the author of this code—it seems that this might be an issue with how libiconv tries to interpret UTF-16 strings without a BOM.[1] Apparently it tries to guess endianness based on the current OS, so one gets different results on different machines. When I changed "UTF-16" to "UTF-16LE" on L336 of MSCompoundFileReader.php, to force little-endian byte order always, the test passed on macOS.

Do you think this would be a proper fix?


[1] https://shreef.com/2010/08/iconv-misunderstands-utf-16-strings-with-no-bom/

Change 521312 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Make MSCompoundFileReader::readFile platform-agnostic

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

Change 521312 merged by jenkins-bot:
[mediawiki/core@master] Make MSCompoundFileReader::readFile platform-agnostic

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