silverstripe / silverstripe-sqlite3

SQLite3 DB Adapter for Silverstripe
BSD 3-Clause "New" or "Revised" License
8 stars 19 forks source link

Making the tests green: PDO & other problems #53

Open NightJar opened 5 years ago

NightJar commented 5 years ago

PDO Problems

PDO does not support :memory: $ PDO=1 DB=SQLITE vendor/bin/phpunit -d memory_limit=512M vendor/silverstripe/framework/tests/ --stop-on-error Get the PID: sudo iotop

$ sudo lsof -p 25392 | grep sqlite
php     25392 nightjar    3u   REG   8,35    12824 3302320 /home/nightjar/public_html/silverstripe-sqlite3/:memory:;host=127.0.0.1;charset=utf8-journal
php     25392 nightjar    5uw  REG   8,35  3063808 3280318 /home/nightjar/public_html/silverstripe-sqlite3/:memory:;host=127.0.0.1;charset=utf8

Cool filename :/

$ ls
 app                  composer.json   _configure_database.php         LICENSE                                         phpunit.xml.dist         vendor
 assets               composer.lock   index.php                      ':memory:;host=127.0.0.1;charset=utf8'           README.md                web.config
 code                 _config         install-frameworkmissing.html  ':memory:;host=127.0.0.1;charset=utf8-journal'   _register_database.php
 code-of-conduct.md   _config.php     install.php                     phpcs.xml.dist                                  resources

PDO causes the last remaining red spot on the test suite https://travis-ci.org/silverstripe/silverstripe-sqlite3/builds/443601934

On the bright side, it's only a single test.

1) SilverStripe\ORM\Tests\DataListTest::testAggregateFilters
Failed asserting that actual size 0 matches expected size 1.

On the down side, that test is super helpful with its assertion comments; $this->assertCount(1, ...); appears 7 times.

A little unsettling: PDO just saw the tests stall at 85% while I was typing this. Had to ^C to exit.

~Other~ Travis problems

The test suite does not run from memory. It seems like it will, and it probably does when run from a project (e.g. added as a requirement to installer). Except travis, because the module is the app, not in vendor/ during a travis test.

This seems insignificant, except that I see differences in results when running from memory:

8) SilverStripe\Forms\Tests\NumericFieldTest::testSetSubmittedValue with data set #28 ('fr_FR', 1, '15.000,5', 15000.5, '15 000,5')
Expected input 15.000,5 to be cleaned up as 15 000,5 in locale fr_FR
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'15 000,5'
+'15 000,5'

I suspect it's to do with character encoding. It's always NumericField, and always the locale adaptation business.

This could be setup related (environmental), but should be looked into. Can anyone else replicate?

git clone git@github.com:silverstripe/silverstripe-sqlite3
cd silverstripe-sqlite3
git checkout 2
composer install

Quick memory shim for testing (in a travis-esque manner):

-        return isset($this->parameters['path']) && $this->parameters['path'] === ':memory:';
+        return (
+            isset($this->parameters['path']) && $this->parameters['path'] === ':memory:'
+            || \SilverStripe\Core\Environment::getEnv('SS_SQLITE_DATABASE_PATH') === ':memory:'
+        );

DB=SQLITE vendor/bin/phpunit -d memory_limit=512M vendor/silverstripe/framework/tests/ --stop-on-error

General observation

The Travis setup denotes that we install recipe-cms - however we only ever run the framework tests. Could it not become recipe-core, or simply framework itself? I'm not sure of the impact the presence of extra modules will have on the time it takes to test, is it even worth looking into? Thinking about composer install time & manifest creation time