Closed ping-yee closed 1 year ago
Cannot reproduce in develop
.
$ ./vendor/bin/phpunit tests/system/Cache/Handlers/FileHandlerTest.php
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.12
Configuration: /Users/kenji/work/codeigniter/official/CodeIgniter4/phpunit.xml
....................... 23 / 23 (100%)
Time: 00:06.308, Memory: 14.00 MB
OK (23 tests, 55 assertions)
chmod
does not work as expected for Windows, as far as I know. that's why the failures occur:
$ vendor/bin/phpunit --filter FileHandlerTest --no-coverage
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.12
Configuration: C:\Users\P\Desktop\Web Dev\CodeIgniter4\phpunit.xml.dist
...F...F..........FFFF....... 29 / 29 (100%)
Time: 00:07.399, Memory: 48.00 MB
There were 6 failures:
1) CodeIgniter\Cache\Handlers\FileHandlerTest::testNewWithNonWritablePath
Failed asserting that exception of type "CodeIgniter\Cache\Exceptions\CacheException" is thrown.
2) CodeIgniter\Cache\Handlers\FileHandlerTest::testSave
Failed asserting that true is false.
C:\Users\P\Desktop\Web Dev\CodeIgniter4\tests\system\Cache\Handlers\FileHandlerTest.php:140
3) CodeIgniter\Cache\Handlers\FileHandlerTest::testSaveMode with data set #0 (416, '640')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'640'
+'666'
C:\Users\P\Desktop\Web Dev\CodeIgniter4\tests\system\Cache\Handlers\FileHandlerTest.php:285
4) CodeIgniter\Cache\Handlers\FileHandlerTest::testSaveMode with data set #1 (384, '600')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'600'
+'666'
C:\Users\P\Desktop\Web Dev\CodeIgniter4\tests\system\Cache\Handlers\FileHandlerTest.php:285
5) CodeIgniter\Cache\Handlers\FileHandlerTest::testSaveMode with data set #2 (432, '660')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'660'
+'666'
C:\Users\P\Desktop\Web Dev\CodeIgniter4\tests\system\Cache\Handlers\FileHandlerTest.php:285
6) CodeIgniter\Cache\Handlers\FileHandlerTest::testSaveMode with data set #3 (511, '777')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'777'
+'666'
C:\Users\P\Desktop\Web Dev\CodeIgniter4\tests\system\Cache\Handlers\FileHandlerTest.php:285
FAILURES!
Tests: 29, Assertions: 65, Failures: 6.
The best way here is to have $this->markTestSkipped(...)
for chmod
related tests when running on Windows.
@paulbalandan Thank you! I'll follow what you say and sent a PR.
Does the condition work in WSL2?
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('chmod does not work as expected on Windows');
}
I test the test case CodeIgniter\Commands\GeneratorsTest::testGenerateFileFailsOnUnwritableDirectory
that use this condition but I still get the failure occurred.
$ ./vendor/bin/phpunit tests/system/Commands/GeneratorsTest.php
PHPUnit 9.5.25 #StandWithUkraine
Runtime: PHP 8.1.12
Configuration: /mnt/d/CodeIgniter4/phpunit.xml.dist
Warning: No code coverage driver available
...F... 7 / 7 (100%)
Nexus\PHPUnit\Extension\Tachycardia identified this sole slow test:
⚠ Took 0.87s from 0.50s limit to run CodeIgniter\\Commands\\GeneratorsTest::testGenerateFileCreated
Time: 00:02.210, Memory: 10.00 MB
There was 1 failure:
1) CodeIgniter\Commands\GeneratorsTest::testGenerateFileFailsOnUnwritableDirectory
Failed asserting that 'File created: APPPATH/Filters/Permissions.php\n
\n
' contains "Error while creating file: ".
/mnt/d/CodeIgniter4/tests/system/Commands/GeneratorsTest.php:84
FAILURES!
Tests: 7, Assertions: 11, Failures: 1.
When running on WSL, DIRECTORY_SEPARATOR
is '/'
@ping-yee I've added a PR for is_windows()
function. Can you try if it correctly skips the test?
@paulbalandan Got it. I'll try it later.
@paulbalandan It work! it skip the test case in fileHandlerTest correctly. Waiting for your brench get merged, then I'll sent PR for this issue. Appreciated for your help!
@ping-yee #6884 got merged but no specific WSL support. Please check https://github.com/codeigniter4/CodeIgniter4/pull/6884#issuecomment-1323676629 on how to make chmod work on your WSL
@paulbalandan Got it. I'll try it later.
PHP Version
8.1
CodeIgniter4 Version
4.2.10
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
cli-server (PHP built-in webserver)
Database
No response
What happened?
Steps to Reproduce
Run
./vendor/bin/phpunit tests/system/Cache/Handlers/FileHandlerTest.php
Expected Output
All passed.
Anything else?
No response