Problem

The unit test for /core/tests/Drupal/Tests/Core/File/FileSystemTest.php has a set of bitwise operations performed during test on Windows platform. These operations is causing the unit test to fail unexpectedly. The operations does not seem to do anything useful. Removal of it allows the test to pass.

======Output of Unit Test======

Drupal\Tests\Core\File\FileSystemTest::testChmodFile
Failed asserting that 436 is identical to 438.

\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:176
\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:51

========================

The system I'm testing on:
PHP 7.1.4 32bit
Apache 2.4.25
Windows 7
Drupal 8.4.x

Proposed resolution

The description for this operations seems to hint on compatibility issues that doesn't exists on Windows. The fileperms is returning the integer values accurately on Windows. Thus, I recommend removal of an obsolete function that causes Unit Test to fail on Windows.

[Edit Apr. 9, 2022]:

I agree with the removing of the code that does "Magic Things" for Windows only in \Drupal\Tests\Core\File\FileSystemTest::assertFilePermissions for three reasons

  1. The value of $expected_mode is already the same as $actual_mode before the "Magic Things" happen so there's no need for it (See screenshot here: https://www.drupal.org/files/issues/2022-04-09/2022-04-09_12-51-52.png ).
  2. Also the "Magic Things" currently causes assertFilePermissions to fail on Windows OS:
  3. Testing Drupal\Tests\Core\File\FileSystemTest
    FF......                                                            8 / 8 (100%)
    
    Time: 00:00.083, Memory: 10.00 MB
    
    There were 2 failures:
    
    1) Drupal\Tests\Core\File\FileSystemTest::testChmodFile
    Failed asserting that 436 is identical to 438.
    
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\Constraint\Constraint.php:121
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\Constraint\IsIdentical.php:94
    D:\htdocs\drupal\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:159
    D:\htdocs\drupal\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:59
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\TestResult.php:726
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\TestSuite.php:678
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:670
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\Command.php:143
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\Command.php:96
    
    2) Drupal\Tests\Core\File\FileSystemTest::testChmodDir
    Failed asserting that 509 is identical to 511.
    
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\Constraint\Constraint.php:121
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\Constraint\IsIdentical.php:94
    D:\htdocs\drupal\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:159
    D:\htdocs\drupal\core\tests\Drupal\Tests\Core\File\FileSystemTest.php:73
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\TestResult.php:726
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\Framework\TestSuite.php:678
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:670
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\Command.php:143
    D:\htdocs\drupal\vendor\phpunit\phpunit\src\TextUI\Command.php:96
      
  4. The fact that I need to post a screenshot and the test output, and can't give you a fail-test patch also is another reason for removal: The "Magic Things" code-path is never tested by TestBot since it doesn't run Windows OS. I think since there's no way to test it currently, it shouldn't be in a test in the first place.

Issue fork drupal-2911379

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ProFire created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, fix-for-fileperm.patch, failed testing. View results

ProFire’s picture

Status: Needs work » Needs review
Issue tags: +Unit tests
StatusFileSize
new1.23 KB
michaellenahan’s picture

Issue tags: +Novice
michaellenahan’s picture

Issue tags: +Vienna2017
joshmiller’s picture

Issue tags: -Vienna2017 +Nashville2018

Version: 8.4.0-rc2 » 8.4.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.4.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
spokje’s picture

Version: 9.3.x-dev » 10.0.x-dev
Issue tags: +Bug Smash Initiative
spokje’s picture

Assigned: Unassigned » spokje
Status: Needs review » Needs work
spokje’s picture

Used patch #3 (2911379-fix-for-fileperm.patch) as base for the newly created MR.

spokje’s picture

Issue summary: View changes
spokje’s picture

Status: Needs work » Needs review

Updated IS with my rationale why removing this code is OK.

spokje’s picture

Issue summary: View changes
StatusFileSize
new195.31 KB
spokje’s picture

Issue summary: View changes
spokje’s picture

Assigned: spokje » Unassigned
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Seems like a simple fix.

quietone’s picture

Has this had manual testing on windows?

spokje’s picture

Has this had manual testing on windows?

Can't remember, so officially that would be a No, I guess.

mstrelan’s picture

StatusFileSize
new31.06 KB
new60.61 KB
new60.43 KB

Tested on Windows 10 with PHP 8.2.4 VS16 x64 Non Thread Safe (2023-Mar-14 18:22:42)

Can confirm the test was broken before and is fixed after.

mstrelan’s picture

StatusFileSize
new77.15 KB

Apologies, I forgot to run composer install for the second screenshot in the previous comment. Here is the failing test.

Windows PHP fail

larowlan’s picture

Crediting mstrelan for manual testing. Booting into windows and installing PHP is a massive effort 🙌

  • larowlan committed 6a984c26 on 10.0.x
    Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise...

  • larowlan committed 2b2aebcd on 10.1.x
    Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise...

  • larowlan committed 11ef5e6b on 9.5.x
    Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise...
larowlan’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x and backported to 10.0.x and 9.5.x for consistency

Status: Fixed » Closed (fixed)

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