mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Add unit tests for ArcanistChmodLinter
Summary: Moar test coverage. Test Plan: `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11343
This commit is contained in:
parent
7aa89ddf96
commit
afc53ed322
6 changed files with 32 additions and 3 deletions
|
@ -32,6 +32,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistCapabilityNotSupportedException' => 'workflow/exception/ArcanistCapabilityNotSupportedException.php',
|
||||
'ArcanistCheckstyleXMLLintRenderer' => 'lint/renderer/ArcanistCheckstyleXMLLintRenderer.php',
|
||||
'ArcanistChmodLinter' => 'lint/linter/ArcanistChmodLinter.php',
|
||||
'ArcanistChmodLinterTestCase' => 'lint/linter/__tests__/ArcanistChmodLinterTestCase.php',
|
||||
'ArcanistCloseRevisionWorkflow' => 'workflow/ArcanistCloseRevisionWorkflow.php',
|
||||
'ArcanistCloseWorkflow' => 'workflow/ArcanistCloseWorkflow.php',
|
||||
'ArcanistClosureLinter' => 'lint/linter/ArcanistClosureLinter.php',
|
||||
|
@ -239,6 +240,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistCapabilityNotSupportedException' => 'Exception',
|
||||
'ArcanistCheckstyleXMLLintRenderer' => 'ArcanistLintRenderer',
|
||||
'ArcanistChmodLinter' => 'ArcanistLinter',
|
||||
'ArcanistChmodLinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
||||
'ArcanistCloseRevisionWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistCloseWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistClosureLinter' => 'ArcanistExternalLinter',
|
||||
|
|
|
@ -42,9 +42,11 @@ final class ArcanistChmodLinter extends ArcanistLinter {
|
|||
}
|
||||
|
||||
public function lintPath($path) {
|
||||
if (is_executable($path)) {
|
||||
if ($this->getEngine()->isBinaryFile($path)) {
|
||||
$mime = Filesystem::getMimeType($path);
|
||||
$engine = $this->getEngine();
|
||||
|
||||
if (is_executable($engine->getFilePathOnDisk($path))) {
|
||||
if ($engine->isBinaryFile($path)) {
|
||||
$mime = Filesystem::getMimeType($engine->getFilePathOnDisk($path));
|
||||
|
||||
switch ($mime) {
|
||||
// Archives
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistChmodLinterTestCase extends ArcanistArcanistLinterTestCase {
|
||||
|
||||
public function testLinter() {
|
||||
$this->executeTestsInDirectory(dirname(__FILE__).'/chmod/');
|
||||
}
|
||||
|
||||
}
|
|
@ -86,6 +86,7 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
'hook' => 'optional bool',
|
||||
'config' => 'optional map<string, wild>',
|
||||
'path' => 'optional string',
|
||||
'mode' => 'optional string',
|
||||
));
|
||||
|
||||
$exception = null;
|
||||
|
@ -99,6 +100,11 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
Filesystem::writeFile($tmp, $data);
|
||||
$full_path = (string)$tmp;
|
||||
|
||||
$mode = idx($config, 'mode');
|
||||
if ($mode) {
|
||||
Filesystem::changePermissions($tmp, octdec($mode));
|
||||
}
|
||||
|
||||
$dir = dirname($full_path);
|
||||
$path = basename($full_path);
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
~~~~~~~~~~
|
||||
warning::
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"mode": "0755"}
|
5
src/lint/linter/__tests__/chmod/shebang.lint-test
Normal file
5
src/lint/linter/__tests__/chmod/shebang.lint-test
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"mode": "0755"}
|
Loading…
Reference in a new issue