extends ArcanistArcanistLinterTestCase {
public function testCpplintLint() {
- $linter = new ArcanistCpplintLinter();
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/cpp/',
- $linter,
- $working_copy);
+ new ArcanistCpplintLinter());
}
}
extends ArcanistArcanistLinterTestCase {
public function testFlake8Lint() {
- $linter = new ArcanistFlake8Linter();
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/python/',
- $linter,
- $working_copy);
+ new ArcanistFlake8Linter());
}
}
*/
abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
- public function executeTestsInDirectory($root, $linter, $working_copy) {
+ public function executeTestsInDirectory($root, ArcanistLinter $linter) {
foreach (Filesystem::listDirectory($root, $hidden = false) as $file) {
- $this->lintFile($root.$file, $linter, $working_copy);
+ $this->lintFile($root.$file, $linter);
}
}
- private function lintFile($file, $linter, $working_copy) {
+ private function lintFile($file, $linter) {
$linter = clone $linter;
$contents = Filesystem::readFile($file);
$config = array();
}
- /* TODO: ?
- validate_parameter_list(
+ PhutilTypeSpec::checkMap(
$config,
array(
- ),
- array(
- 'project' => true,
- 'path' => true,
- 'hook' => true,
+ 'project' => 'optional string',
+ 'hook' => 'optional bool',
+ 'config' => 'optional wild',
));
- */
$exception = null;
$after_lint = null;
$caught_exception = false;
try {
- $path = idx($config, 'path', 'lint/'.$basename.'.php');
+ $tmp = new TempFile($basename);
+ Filesystem::writeFile($tmp, $data);
+ $full_path = (string)$tmp;
+
+ $dir = dirname($full_path);
+ $path = basename($full_path);
+ $working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile(
+ $dir,
+ null,
+ 'Unit Test');
$engine = new UnitTestableArcanistLintEngine();
$engine->setWorkingCopy($working_copy);
$engine->addFileData($path, $data);
$results = $engine->run();
+
$this->assertEqual(
1,
count($results),
'deprecated_function' => 'This function is most likely deprecated.',
));
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/phlxhp/',
- $linter,
- $working_copy);
+ $linter);
}
}
final class ArcanistRubyLinterTestCase extends ArcanistArcanistLinterTestCase {
public function testRubyLint() {
- $linter = new ArcanistRubyLinter();
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/ruby/',
- $linter,
- $working_copy);
+ new ArcanistRubyLinter());
}
}
$linter->removeLintRule('acc'.'out');
$linter->addPartialWordRule('supermn', 'superman');
$linter->addWholeWordRule('batmn', 'batman');
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
+
return $this->executeTestsInDirectory(
dirname(__FILE__).'/spelling/',
- $linter,
- $working_copy);
+ $linter);
}
public function testFixLetterCase() {
final class ArcanistTextLinterTestCase extends ArcanistArcanistLinterTestCase {
public function testTextLint() {
- $linter = new ArcanistTextLinter();
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/text/',
- $linter,
- $working_copy);
+ new ArcanistTextLinter());
}
}
=> ArcanistLintSeverity::SEVERITY_WARNING,
));
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__);
return $this->executeTestsInDirectory(
dirname(__FILE__).'/xhpast/',
- $linter,
- $working_copy);
+ $linter);
}
}
$config_raw,
$from_where) {
- $config = self::parseRawConfigFile($config_raw, $from_where);
+ if ($config_raw === null) {
+ $config = array();
+ } else {
+ $config = self::parseRawConfigFile($config_raw, $from_where);
+ }
+
return new ArcanistWorkingCopyIdentity($root, $config);
}