1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +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',
'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',

View file

@ -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

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',
'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);

View file

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

View file

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