Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/phutil/PhutilTestCase.php
| Show All 14 Lines | abstract class PhutilTestCase extends Phobject { | ||||
| private $testStartTime; | private $testStartTime; | ||||
| private $results = array(); | private $results = array(); | ||||
| private $enableCoverage; | private $enableCoverage; | ||||
| private $coverage = array(); | private $coverage = array(); | ||||
| private $workingCopy; | private $workingCopy; | ||||
| private $paths; | private $paths; | ||||
| private $renderer; | private $renderer; | ||||
| private static $executables = array(); | |||||
| /* -( Making Test Assertions )--------------------------------------------- */ | /* -( Making Test Assertions )--------------------------------------------- */ | ||||
| /** | /** | ||||
| * Assert that a value is `false`, strictly. The test fails if it is not. | * Assert that a value is `false`, strictly. The test fails if it is not. | ||||
| * | * | ||||
| * @param wild The empirically derived value, generated by executing the | * @param wild The empirically derived value, generated by executing the | ||||
| ▲ Show 20 Lines • Show All 712 Lines • ▼ Show 20 Lines | private function failAssertionWithExpectedValue( | ||||
| $actual_result = PhutilReadableSerializer::printableValue($actual_result); | $actual_result = PhutilReadableSerializer::printableValue($actual_result); | ||||
| $header = pht('ACTUAL VALUE'); | $header = pht('ACTUAL VALUE'); | ||||
| $output = $description."\n\n".$header."\n".$actual_result; | $output = $description."\n\n".$header."\n".$actual_result; | ||||
| $this->failTest($output); | $this->failTest($output); | ||||
| throw new PhutilTestTerminatedException($output); | throw new PhutilTestTerminatedException($output); | ||||
| } | } | ||||
| final protected function assertExecutable($binary) { | |||||
| if (!isset(self::$executables[$binary])) { | |||||
| switch ($binary) { | |||||
| case 'xhpast': | |||||
| $ok = true; | |||||
| if (!PhutilXHPASTBinary::isAvailable()) { | |||||
| try { | |||||
| PhutilXHPASTBinary::build(); | |||||
| } catch (Exception $ex) { | |||||
| $ok = false; | |||||
| } | |||||
| } | |||||
| break; | |||||
| default: | |||||
| $ok = Filesystem::binaryExists($binary); | |||||
| break; | |||||
| } | |||||
| self::$executables[$binary] = $ok; | |||||
| } | |||||
| if (!self::$executables[$binary]) { | |||||
| $this->assertSkipped( | |||||
| pht('Required executable "%s" is not available.', $binary)); | |||||
| } | |||||
| } | |||||
| final protected function getSupportExecutable($executable) { | |||||
| $root = dirname(phutil_get_library_root('arcanist')); | |||||
| return $root.'/support/unit/'.$executable.'.php'; | |||||
| } | |||||
| } | } | ||||