1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Further improvements to test discovery

Summary: I found another issue with T8042... it seems that tests from the root directory (i.e. `src/__tests__` are not being discovered properly). The handling of this case (`$library_path` being the library root directory) can probably be improved, and I am open to suggestions. Depends on D13202.

Test Plan: Added to existing test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D13185
This commit is contained in:
Joshua Spence 2015-06-15 07:23:17 +10:00
parent 7d15b85a1b
commit 3c3438714b
2 changed files with 23 additions and 20 deletions

View file

@ -197,20 +197,21 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine {
continue;
}
if ($path == $library_root) {
$paths[$library_name.':.'] = array(
'library' => $library_name,
'path' => '__tests__/',
);
continue;
}
foreach (Filesystem::walkToRoot($path, $library_root) as $subpath) {
if ($subpath == $library_root) {
$paths[$library_name.':.'] = array(
'library' => $library_name,
'path' => '__tests__/',
);
} else {
$library_subpath = Filesystem::readablePath($subpath, $library_root);
do {
$paths[$library_name.':'.$library_path] = array(
'library' => $library_name,
'path' => $library_path.'/__tests__/',
);
} while (($library_path = dirname($library_path)) != '.');
$paths[$library_name.':'.$library_subpath] = array(
'library' => $library_name,
'path' => $library_subpath.'/__tests__/',
);
}
}
}
return $paths;

View file

@ -142,6 +142,7 @@ final class PhutilUnitTestEngineTestCase extends PhutilTestCase {
dirname(dirname(__FILE__)).'/__tests__/',
dirname(dirname(dirname(__FILE__))).'/__tests__/',
phutil_get_library_root('arcanist').'/__tests__/',
),
),
'normal directory' => array(
@ -151,25 +152,26 @@ final class PhutilUnitTestEngineTestCase extends PhutilTestCase {
array(
dirname(dirname(__FILE__)).'/__tests__/',
dirname(dirname(dirname(__FILE__))).'/__tests__/',
phutil_get_library_root('arcanist').'/__tests__/',
),
),
'library root' => array(
array(phutil_get_library_root()),
array(phutil_get_library_root().'/__tests__/'),
array(phutil_get_library_root('arcanist')),
array(phutil_get_library_root('arcanist').'/__tests__/'),
),
);
$test_engine = id(new PhutilUnitTestEngine())
->setWorkingCopy($this->getWorkingCopy());
$library = phutil_get_current_library_name();
$library_root = phutil_get_library_root($library);
foreach ($tests as $name => $test) {
list($paths, $tests) = $test;
list($paths, $test_paths) = $test;
$expected = array();
foreach ($tests as $path) {
$library_root = phutil_get_library_root_for_path($path);
$library = phutil_get_library_name_for_root($library_root);
foreach ($test_paths as $path) {
$expected[] = array(
'library' => $library,
'path' => Filesystem::readablePath($path, $library_root),