Page MenuHomePhabricator

D12689.id30465.diff
No OneTemporary

D12689.id30465.diff

diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php
--- a/src/unit/engine/PhutilUnitTestEngine.php
+++ b/src/unit/engine/PhutilUnitTestEngine.php
@@ -17,16 +17,21 @@
}
if (!$run_tests) {
- throw new ArcanistNoEffectException('No tests to run.');
+ throw new ArcanistNoEffectException(pht('No tests to run.'));
}
$enable_coverage = $this->getEnableCoverage();
+
if ($enable_coverage !== false) {
if (!function_exists('xdebug_start_code_coverage')) {
if ($enable_coverage === true) {
throw new ArcanistUsageException(
- 'You specified --coverage but xdebug is not available, so '.
- 'coverage can not be enabled for PhutilUnitTestEngine.');
+ pht(
+ 'You specified %s but %s is not available, so '.
+ 'coverage can not be enabled for %s.',
+ '--coverage',
+ 'XDebug',
+ __CLASS__));
}
} else {
$enable_coverage = true;
@@ -125,31 +130,27 @@
}
$path = Filesystem::resolvePath($path, $project_root);
+ $library_path = Filesystem::readablePath($path, $library_root);
- if (!is_dir($path)) {
- $path = dirname($path);
- }
-
- if ($path == $library_root) {
- $look_here[$library_name.':.'] = array(
- 'library' => $library_name,
- 'path' => '',
- );
- } else if (!Filesystem::isDescendant($path, $library_root)) {
+ if (!Filesystem::isDescendant($path, $library_root)) {
// We have encountered some kind of symlink maze -- for instance, $path
// is some symlink living outside the library that links into some file
// inside the library. Just ignore these cases, since the affected file
// does not actually lie within the library.
continue;
+ } else if (is_file($path) && preg_match('/\b__tests__\b/', $path)) {
+ $look_here[$library_name.':'.$library_path] = array(
+ 'library' => $library_name,
+ 'path' => $library_path,
+ );
} else {
- $library_path = Filesystem::readablePath($path, $library_root);
do {
$look_here[$library_name.':'.$library_path] = array(
'library' => $library_name,
- 'path' => $library_path,
+ 'path' => $library_path == $library_root ? '' : $library_path,
);
$library_path = dirname($library_path);
- } while ($library_path != '.');
+ } while ($library_path != '.' && $library_path == $library_root);
}
}
@@ -170,7 +171,7 @@
$symbols = id(new PhutilSymbolLoader())
->setType('class')
->setLibrary($library)
- ->setPathPrefix(($path ? $path.'/' : '').'__tests__/')
+ ->setPathPrefix($path)
->setAncestorClass('ArcanistPhutilTestCase')
->setConcreteOnly(true)
->selectAndLoadSymbols();

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 19, 6:17 AM (5 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7710927
Default Alt Text
D12689.id30465.diff (2 KB)

Event Timeline