Page MenuHomePhabricator

D11515.id.diff
No OneTemporary

D11515.id.diff

diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php
--- a/src/unit/engine/PhpunitTestEngine.php
+++ b/src/unit/engine/PhpunitTestEngine.php
@@ -129,7 +129,7 @@
substr($file, 0, -4).'Test.php',
);
- $search = self::getSearchLocationsForTests($path);
+ $search = $this->getSearchLocationsForTests($path);
foreach ($search as $search_path) {
foreach ($possible_files as $possible_file) {
@@ -193,11 +193,16 @@
* @param string PHP file to locate test cases for.
* @return list<string> List of directories to search for tests in.
*/
- public static function getSearchLocationsForTests($path) {
+ public function getSearchLocationsForTests($path) {
$file = basename($path);
$dir = dirname($path);
- $test_dir_names = array('tests', 'Tests');
+ $test_dir_names = $this->getConfigurationManager()->getConfigFromAnySource(
+ 'phpunit_test_dirs');
+
+ if (empty($test_dir_names)) {
+ $test_dir_names = array('tests', 'Tests');
+ }
$try_directories = array();
diff --git a/src/unit/engine/__tests__/PHPUnitTestEngineTestCase.php b/src/unit/engine/__tests__/PHPUnitTestEngineTestCase.php
--- a/src/unit/engine/__tests__/PHPUnitTestEngineTestCase.php
+++ b/src/unit/engine/__tests__/PHPUnitTestEngineTestCase.php
@@ -8,6 +8,14 @@
public function testSearchLocations() {
$path = '/path/to/some/file/X.php';
+ $root = dirname(phutil_get_library_root('arcanist'));
+ $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
+ $configuration_manager = new ArcanistConfigurationManager();
+ $configuration_manager->setWorkingCopyIdentity($working_copy);
+
+ $phpunitTestEngine = new PhpunitTestEngine();
+ $phpunitTestEngine->setConfigurationManager($configuration_manager);
+
$this->assertEqual(
array(
'/path/to/some/file/',
@@ -36,7 +44,38 @@
'/tests/path/to/some/file/',
'/Tests/path/to/some/file/',
),
- PhpunitTestEngine::getSearchLocationsForTests($path));
+ $phpunitTestEngine->getSearchLocationsForTests($path));
+ }
+
+ public function testConfiguredSearchLocations() {
+ $path = '/path/to/some/file/X.php';
+
+ $root = dirname(phutil_get_library_root('arcanist'));
+ $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
+ $configuration_manager = new ArcanistConfigurationManager();
+ $configuration_manager->setWorkingCopyIdentity($working_copy);
+ $configuration_manager->setRuntimeConfig(
+ 'phpunit_test_dirs', array('tests/Unit'));
+ $phpunitTestEngine = new PhpunitTestEngine();
+ $phpunitTestEngine->setConfigurationManager($configuration_manager);
+
+ $this->assertEqual(
+ array(
+ '/path/to/some/file/',
+ '/path/to/some/file/tests/Unit/',
+ '/path/to/some/tests/Unit/',
+ '/path/to/tests/Unit/',
+ '/path/tests/Unit/',
+ '/tests/Unit/',
+ '/path/to/tests/Unit/file/',
+ '/path/tests/Unit/some/file/',
+ '/tests/Unit/to/some/file/',
+ '/path/to/some/tests/Unit/file/',
+ '/path/to/tests/Unit/some/file/',
+ '/path/tests/Unit/to/some/file/',
+ '/tests/Unit/path/to/some/file/',
+ ),
+ $phpunitTestEngine->getSearchLocationsForTests($path));
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 31, 11:45 PM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7442881
Default Alt Text
D11515.id.diff (3 KB)

Event Timeline