From 457b91f6cb3188e9e7630e8c9da9c84e1529ded0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 6 Mar 2013 13:53:48 -0800 Subject: [PATCH] Improve performance of Phabricator unit tests Summary: Build one fixture total, not one per test case. Depends on D5258. Test Plan: `arc unit --everything` Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D5259 --- .../testing/PhabricatorTestCase.php | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/infrastructure/testing/PhabricatorTestCase.php b/src/infrastructure/testing/PhabricatorTestCase.php index dbdd1ef126..12f18567bc 100644 --- a/src/infrastructure/testing/PhabricatorTestCase.php +++ b/src/infrastructure/testing/PhabricatorTestCase.php @@ -56,22 +56,35 @@ abstract class PhabricatorTestCase extends ArcanistPhutilTestCase { return $config; } - protected function willRunTests() { + public function willRunTestCases(array $test_cases) { $root = dirname(phutil_get_library_root('phabricator')); require_once $root.'/scripts/__init_script__.php'; $config = $this->getComputedConfiguration(); - if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) { - LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess(); - } - if ($config[self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES]) { ++self::$storageFixtureReferences; if (!self::$storageFixture) { self::$storageFixture = $this->newStorageFixture(); } } + } + + public function didRunTestCases(array $test_cases) { + if (self::$storageFixture) { + self::$storageFixtureReferences--; + if (!self::$storageFixtureReferences) { + self::$storageFixture = null; + } + } + } + + protected function willRunTests() { + $config = $this->getComputedConfiguration(); + + if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) { + LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess(); + } $this->env = PhabricatorEnv::beginScopedEnv(); } @@ -83,13 +96,6 @@ abstract class PhabricatorTestCase extends ArcanistPhutilTestCase { LiskDAO::endIsolateAllLiskEffectsToCurrentProcess(); } - if (self::$storageFixture) { - self::$storageFixtureReferences--; - if (!self::$storageFixtureReferences) { - self::$storageFixture = null; - } - } - try { if (phutil_is_hiphop_runtime()) { $this->env->__destruct();