Create a test env for php, php-memcached and hhvm and apply PR #11565.
sudo service memcached restart
View libraries/vendor/phpunit/phpunit/phpunit. It should start like:
#!/usr/bin/env php
Run libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMemcachedTest
PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
Warning: The Xdebug extension is not loaded
No code coverage will be generated........
Time: 5.08 seconds, Memory: 8.00MB
OK (7 tests, 17 assertions)
Edit libraries/vendor/phpunit/phpunit/phpunit
and replace first like from php to hhvm.
Should be: #!/usr/bin/env hhvm
Run libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMemcacheTest
PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
Warning: The Xdebug extension is not loaded
No code coverage will be generated.Fatal error: [] operator not supported for strings in libraries/joomla/cache/storage/memcache.php on line 194
Run sudo service memcached restart
(The same as point 6) Run libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMemcacheTest
PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
Warning: The Xdebug extension is not loaded
No code coverage will be generated........
Time: 9.17 seconds, Memory: 28.64MB
OK (7 tests, 17 assertions)
Memcache Test for HHVM should pass on PR #11565
but did not pass because it was run after memcached storage did test which left empty array in memcached server.
I suggest to restart memcached server before each memcache/memcached tests.
Memcache storage test fails if memcached server has value from memcached tests.
I thought it would solve the problem
but on second thought I would not force users to reset server after change cache handler between memcache and memcached.
Then this issue may be incorrect.
I have plan to add new change to memcache storage and strict check if $index
is array.
What you proposed was forcing the unit test to reset the cache handler between unit tests.
Since unit tests should be independent and isolated, resetting the cache handler between the tests makes sense as it maintains the isolation between tests.
(On a side note: on the user end, either a strict check for array and handling that case, or the array_push() I suggested ensures the end users don't run into a fatal error related to MEMCACHE::get returning a string.)
If you want to do reset cache then please create (IMHO) a new PR for that.
I not enough familiar with unit tests.
Labels |
Added:
?
|
Category | ⇒ | Unit Tests |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-18 23:58:21 |
Closed_By | ⇒ | csthomas |
I agree, it doesn't make a lot of sense that we are not resetting/restarting caching servers prior to each Unit test being run.
The suggested fix might be something to add to my PR relating to memory management of the unit tests. #10685