Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/__tests__/ArcanistLinterTestCase.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | $this->assertTrue( | ||||
'Expected to find some %s tests in directory %s!', | 'Expected to find some %s tests in directory %s!', | ||||
'.lint-test', | '.lint-test', | ||||
$root)); | $root)); | ||||
} | } | ||||
private function lintFile($file, ArcanistLinter $linter) { | private function lintFile($file, ArcanistLinter $linter) { | ||||
$linter = clone $linter; | $linter = clone $linter; | ||||
if (!$linter->canRun()) { | |||||
$this->assertSkipped( | |||||
pht( | |||||
'Linter "%s" can not run.', | |||||
get_class($linter))); | |||||
} | |||||
$contents = Filesystem::readFile($file); | $contents = Filesystem::readFile($file); | ||||
$contents = preg_split('/^~{4,}\n/m', $contents); | $contents = preg_split('/^~{4,}\n/m', $contents); | ||||
if (count($contents) < 2) { | if (count($contents) < 2) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"Expected '%s' separating test case and results.", | "Expected '%s' separating test case and results.", | ||||
'~~~~~~~~~~')); | '~~~~~~~~~~')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | if ($missing || $surprising) { | ||||
'Lint emitted an unexpected set of messages for file "%s".', | 'Lint emitted an unexpected set of messages for file "%s".', | ||||
$file), | $file), | ||||
$this->renderMessages(pht('MISSING MESSAGES'), $missing), | $this->renderMessages(pht('MISSING MESSAGES'), $missing), | ||||
$this->renderMessages(pht('SURPLUS MESSAGES'), $surprising))); | $this->renderMessages(pht('SURPLUS MESSAGES'), $surprising))); | ||||
} | } | ||||
} | } | ||||
private function compareTransform($expected, $actual) { | private function compareTransform($expected, $actual) { | ||||
$expected = phutil_string_cast($expected); | |||||
if (!strlen($expected)) { | if (!strlen($expected)) { | ||||
return; | return; | ||||
} | } | ||||
$this->assertEqual( | $this->assertEqual( | ||||
$expected, | $expected, | ||||
$actual, | $actual, | ||||
pht('File as patched by lint did not match the expected patched file.')); | pht('File as patched by lint did not match the expected patched file.')); | ||||
} | } | ||||
/** | /** | ||||
* Compare properties of @{class:ArcanistLintMessage} instances. | * Compare properties of @{class:ArcanistLintMessage} instances. | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |