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 | public function executeTestsInDirectory( | ||||
| } | } | ||||
| $this->assertTrue( | $this->assertTrue( | ||||
| ($test_count > 0), | ($test_count > 0), | ||||
| pht('Expected to find some .lint-test tests in directory %s!', $root)); | pht('Expected to find some .lint-test tests in directory %s!', $root)); | ||||
| } | } | ||||
| private function lintFile($file, ArcanistLinter $linter) { | private function lintFile($file, ArcanistLinter $linter) { | ||||
| $linter = clone $linter; | $linter = clone $linter; | ||||
sectioneight: This might fit better in the $config section below, which is intended to be a flexible JSON… | |||||
| $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 All 13 Lines | private function lintFile($file, ArcanistLinter $linter) { | ||||
| PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
| $config, | $config, | ||||
| array( | array( | ||||
| 'hook' => 'optional bool', | 'hook' => 'optional bool', | ||||
| 'config' => 'optional map<string, wild>', | 'config' => 'optional map<string, wild>', | ||||
| 'path' => 'optional string', | 'path' => 'optional string', | ||||
| 'mode' => 'optional string', | 'mode' => 'optional string', | ||||
| 'stopped' => 'optional bool', | 'stopped' => 'optional bool', | ||||
| 'file_extension' => 'optional string', | |||||
joshuaspenceUnsubmitted Not Done Inline ActionsWe don't want this change... the linter (go vet in this case) should lint whatever path is explicitly passed to it, regardless of the file extension. joshuaspence: We don't want this change... the linter (`go vet` in this case) should lint whatever path is… | |||||
eMxyzptlkAuthorUnsubmitted Not Done Inline ActionsUnfortunately it does not work. Go vet expects the file to end with .go $ go tool vet src/lint/linter/__tests__/govet/fmt.lint-test vet: no files checked eMxyzptlk: Unfortunately it does not work. Go vet expects the file to end with `.go`
```
$ go tool vet… | |||||
| )); | )); | ||||
Not Done Inline ActionsIf that's the case then I don't think that this linter should be upstreamed just yet. I don't like adding this functionality for only one subclass. Furthermore, I find this behavior to be counterintuitive. If my .arclint file says to lint *.txt files with ArcanistGoVetLinter, it would not be obvious why this wouldn't be working. I think that if we did want this functionality then we should add a getSupportedFileExtensions() method to ArcanistLinter. joshuaspence: If that's the case then I don't think that this linter should be upstreamed just yet. I don't… | |||||
Not Done Inline ActionsBlessed Reviewers thoughts on this? eMxyzptlk: #blessed_reviewers thoughts on this? | |||||
| $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 { | ||||
| $file_extension = idx($config, 'file_extension', ''); | |||||
| $tmp = new TempFile($basename); | $tmp = new TempFile($basename); | ||||
| if (!empty($file_extension)) { | |||||
| $tmp .= '.'.$file_extension; | |||||
| } | |||||
| 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)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines | |||||
This might fit better in the $config section below, which is intended to be a flexible JSON hash already, and would allow other tests to opt-in on a per-file basis. I'll let the blessed reviewers decide though :)