Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15458405
D11515.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11515.id.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D11515: Add configuration option for PHPUnit test dirs
Attached
Detach File
Event Timeline
Log In to Comment