Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/__tests__/ArcanistLinterTestCase.php
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | private function lintFile($file, ArcanistLinter $linter) { | ||||
| if ($config) { | if ($config) { | ||||
| $config = phutil_json_decode($config); | $config = phutil_json_decode($config); | ||||
| } else { | } else { | ||||
| $config = array(); | $config = array(); | ||||
| } | } | ||||
| PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
| $config, | $config, | ||||
| array( | array( | ||||
| 'hook' => 'optional bool', | 'arcconfig' => 'optional map<string, wild>', | ||||
| 'config' => 'optional map<string, wild>', | 'config' => 'optional map<string, wild>', | ||||
| 'path' => 'optional string', | 'hook' => 'optional bool', | ||||
| 'mode' => 'optional string', | 'mode' => 'optional string', | ||||
| 'path' => 'optional string', | |||||
| 'stopped' => 'optional bool', | 'stopped' => 'optional bool', | ||||
| )); | )); | ||||
| $exception = null; | $exception = null; | ||||
| $after_lint = null; | $after_lint = null; | ||||
| $messages = null; | $messages = null; | ||||
| $exception_message = false; | $exception_message = false; | ||||
| $caught_exception = false; | $caught_exception = false; | ||||
| try { | try { | ||||
| $tmp = new TempFile($basename); | $tmp = new TempFile($basename); | ||||
| Filesystem::writeFile($tmp, $data); | Filesystem::writeFile($tmp, $data); | ||||
| $full_path = (string)$tmp; | $full_path = (string)$tmp; | ||||
| $mode = idx($config, 'mode'); | $mode = idx($config, 'mode'); | ||||
| if ($mode) { | if ($mode) { | ||||
| Filesystem::changePermissions($tmp, octdec($mode)); | Filesystem::changePermissions($tmp, octdec($mode)); | ||||
| } | } | ||||
| $dir = dirname($full_path); | $dir = dirname($full_path); | ||||
| $path = basename($full_path); | $path = basename($full_path); | ||||
| $config_file = null; | |||||
| $arcconfig = idx($config, 'arcconfig'); | |||||
| if ($arcconfig) { | |||||
| $config_file = json_encode($arcconfig); | |||||
| } | |||||
| $working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile( | $working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile( | ||||
| $dir, | $dir, | ||||
| null, | $config_file, | ||||
| 'Unit Test'); | 'Unit Test'); | ||||
| $configuration_manager = new ArcanistConfigurationManager(); | $configuration_manager = new ArcanistConfigurationManager(); | ||||
| $configuration_manager->setWorkingCopyIdentity($working_copy); | $configuration_manager->setWorkingCopyIdentity($working_copy); | ||||
| $engine = new ArcanistUnitTestableLintEngine(); | $engine = new ArcanistUnitTestableLintEngine(); | ||||
| $engine->setWorkingCopy($working_copy); | $engine->setWorkingCopy($working_copy); | ||||
| $engine->setConfigurationManager($configuration_manager); | $engine->setConfigurationManager($configuration_manager); | ||||
| ▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines | |||||