Page MenuHomePhabricator

Running tests with --reuse-db (and partially with --use-normal-tables) became useless, because MediaWikiIntegrationTestCase now always deletes tables, even in --use-normal-tables mode
Open, Needs TriagePublic

Description

It appears that --reuse-db parameter of phpunit.php is broken now.

Its usecase was:

  1. first, you run one small test with --use-normal-tables. This causes all unittest_ tables to be created by cloning (possibly slow).
  2. then you run all other tests with --use-normal-tables --reuse-db, thus bypassing the need to copy tables (which is what CloneDatabase does). Skipping the clone greatly improves performance.

The cause is: recently the following line was added to tests/phpunit/MediaWikiIntegrationTestCase.php:

self::$dbClone->destroy( true );

This true results in all tables created by phpunit (even when --use-normal-tables are used) to be unconditionally deleted (there is no way to disable it). This makes --reuse-db impossible.

There is another impact: --use-normal-tables was very useful for manual troubleshooting (you could inspect the state of database after a failed test). Now that the table is always deleted, this is also not possible.

Event Timeline

  1. Its removal should be reverted. It was removed without understanding of its usecase (see above), and there is no benefit to it being removed.
  2. Even without --reuse-db, a second issue ("due to tables now being deleted, --use-normal-tables now can't be used for inspecting the database after a failed test") still remains.
  3. T283146 incorrectly implies that --use-normal-tables was useless due to table truncation. This is wrong, because phpunit can be called with --stop-on-failure, which ensures that no other tests run after the failed test (meaning that tables won't be truncated: they are truncated at the beginning of tests).

@daniel Do you have any objections to reverting T283146?