Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | $tests = array( | ||||
dirname(__FILE__), | dirname(__FILE__), | ||||
), | ), | ||||
array( | array( | ||||
// This is odd, but harmless. | // This is odd, but harmless. | ||||
dirname(dirname(__FILE__)).'/__tests__/__tests__/', | dirname(dirname(__FILE__)).'/__tests__/__tests__/', | ||||
dirname(dirname(__FILE__)).'/__tests__/', | dirname(dirname(__FILE__)).'/__tests__/', | ||||
dirname(dirname(dirname(__FILE__))).'/__tests__/', | dirname(dirname(dirname(__FILE__))).'/__tests__/', | ||||
phutil_get_library_root('arcanist').'/__tests__/', | |||||
), | ), | ||||
), | ), | ||||
'normal directory' => array( | 'normal directory' => array( | ||||
array( | array( | ||||
dirname(dirname(__FILE__)), | dirname(dirname(__FILE__)), | ||||
), | ), | ||||
array( | array( | ||||
dirname(dirname(__FILE__)).'/__tests__/', | dirname(dirname(__FILE__)).'/__tests__/', | ||||
dirname(dirname(dirname(__FILE__))).'/__tests__/', | dirname(dirname(dirname(__FILE__))).'/__tests__/', | ||||
phutil_get_library_root('arcanist').'/__tests__/', | |||||
), | ), | ||||
), | ), | ||||
'library root' => array( | 'library root' => array( | ||||
array(phutil_get_library_root()), | array(phutil_get_library_root('arcanist')), | ||||
array(phutil_get_library_root().'/__tests__/'), | array(phutil_get_library_root('arcanist').'/__tests__/'), | ||||
), | ), | ||||
); | ); | ||||
$test_engine = id(new PhutilUnitTestEngine()) | $test_engine = id(new PhutilUnitTestEngine()) | ||||
->setWorkingCopy($this->getWorkingCopy()); | ->setWorkingCopy($this->getWorkingCopy()); | ||||
$library = phutil_get_current_library_name(); | |||||
$library_root = phutil_get_library_root($library); | |||||
foreach ($tests as $name => $test) { | foreach ($tests as $name => $test) { | ||||
list($paths, $tests) = $test; | list($paths, $test_paths) = $test; | ||||
$expected = array(); | $expected = array(); | ||||
foreach ($tests as $path) { | foreach ($test_paths as $path) { | ||||
$library_root = phutil_get_library_root_for_path($path); | |||||
$library = phutil_get_library_name_for_root($library_root); | |||||
$expected[] = array( | $expected[] = array( | ||||
'library' => $library, | 'library' => $library, | ||||
'path' => Filesystem::readablePath($path, $library_root), | 'path' => Filesystem::readablePath($path, $library_root), | ||||
); | ); | ||||
} | } | ||||
$test_engine->setPaths($paths); | $test_engine->setPaths($paths); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
$expected, | $expected, | ||||
array_values($test_engine->getTestPaths()), | array_values($test_engine->getTestPaths()), | ||||
pht('Test paths for: "%s"', $name)); | pht('Test paths for: "%s"', $name)); | ||||
} | } | ||||
} | } | ||||
} | } |