1
0
Fork 0
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:
Joshua Spence 2015-01-15 06:58:10 +11:00
parent 7aa89ddf96
commit afc53ed322
6 changed files with 32 additions and 3 deletions

View file

@ -32,6 +32,7 @@ phutil_register_library_map(array(
'ArcanistCapabilityNotSupportedException' => 'workflow/exception/ArcanistCapabilityNotSupportedException.php', 'ArcanistCapabilityNotSupportedException' => 'workflow/exception/ArcanistCapabilityNotSupportedException.php',
'ArcanistCheckstyleXMLLintRenderer' => 'lint/renderer/ArcanistCheckstyleXMLLintRenderer.php', 'ArcanistCheckstyleXMLLintRenderer' => 'lint/renderer/ArcanistCheckstyleXMLLintRenderer.php',
'ArcanistChmodLinter' => 'lint/linter/ArcanistChmodLinter.php', 'ArcanistChmodLinter' => 'lint/linter/ArcanistChmodLinter.php',
'ArcanistChmodLinterTestCase' => 'lint/linter/__tests__/ArcanistChmodLinterTestCase.php',
'ArcanistCloseRevisionWorkflow' => 'workflow/ArcanistCloseRevisionWorkflow.php', 'ArcanistCloseRevisionWorkflow' => 'workflow/ArcanistCloseRevisionWorkflow.php',
'ArcanistCloseWorkflow' => 'workflow/ArcanistCloseWorkflow.php', 'ArcanistCloseWorkflow' => 'workflow/ArcanistCloseWorkflow.php',
'ArcanistClosureLinter' => 'lint/linter/ArcanistClosureLinter.php', 'ArcanistClosureLinter' => 'lint/linter/ArcanistClosureLinter.php',
@ -239,6 +240,7 @@ phutil_register_library_map(array(
'ArcanistCapabilityNotSupportedException' => 'Exception', 'ArcanistCapabilityNotSupportedException' => 'Exception',
'ArcanistCheckstyleXMLLintRenderer' => 'ArcanistLintRenderer', 'ArcanistCheckstyleXMLLintRenderer' => 'ArcanistLintRenderer',
'ArcanistChmodLinter' => 'ArcanistLinter', 'ArcanistChmodLinter' => 'ArcanistLinter',
'ArcanistChmodLinterTestCase' => 'ArcanistArcanistLinterTestCase',
'ArcanistCloseRevisionWorkflow' => 'ArcanistWorkflow', 'ArcanistCloseRevisionWorkflow' => 'ArcanistWorkflow',
'ArcanistCloseWorkflow' => 'ArcanistWorkflow', 'ArcanistCloseWorkflow' => 'ArcanistWorkflow',
'ArcanistClosureLinter' => 'ArcanistExternalLinter', 'ArcanistClosureLinter' => 'ArcanistExternalLinter',

View file

@ -42,9 +42,11 @@ final class ArcanistChmodLinter extends ArcanistLinter {
} }
public function lintPath($path) { public function lintPath($path) {
if (is_executable($path)) { $engine = $this->getEngine();
if ($this->getEngine()->isBinaryFile($path)) {
$mime = Filesystem::getMimeType($path); if (is_executable($engine->getFilePathOnDisk($path))) {
if ($engine->isBinaryFile($path)) {
$mime = Filesystem::getMimeType($engine->getFilePathOnDisk($path));
switch ($mime) { switch ($mime) {
// Archives // Archives

View file

@ -0,0 +1,9 @@
<?php
final class ArcanistChmodLinterTestCase extends ArcanistArcanistLinterTestCase {
public function testLinter() {
$this->executeTestsInDirectory(dirname(__FILE__).'/chmod/');
}
}

View file

@ -86,6 +86,7 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
'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',
)); ));
$exception = null; $exception = null;
@ -99,6 +100,11 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
Filesystem::writeFile($tmp, $data); Filesystem::writeFile($tmp, $data);
$full_path = (string)$tmp; $full_path = (string)$tmp;
$mode = idx($config, 'mode');
if ($mode) {
Filesystem::changePermissions($tmp, octdec($mode));
}
$dir = dirname($full_path); $dir = dirname($full_path);
$path = basename($full_path); $path = basename($full_path);

View file

@ -0,0 +1,5 @@
~~~~~~~~~~
warning::
~~~~~~~~~~
~~~~~~~~~~
{"mode": "0755"}

View file

@ -0,0 +1,5 @@
#!/bin/bash
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
{"mode": "0755"}