mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
Declare is_executable as static and remove its unit tests.
Testing the public interface mch_can_exe should suffice. Every former test of is_executable has a counterpart in the tests of mch_can_exe. Thus we can keep private things private.
This commit is contained in:
parent
d5b223afe2
commit
ef03a8c52a
@ -192,12 +192,12 @@ int mch_isdir(char_u *name)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_executable(char_u *name);
|
static int is_executable(char_u *name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return 1 if "name" is an executable file, 0 if not or it doesn't exist.
|
* Return 1 if "name" is an executable file, 0 if not or it doesn't exist.
|
||||||
*/
|
*/
|
||||||
int is_executable(char_u *name)
|
static int is_executable(char_u *name)
|
||||||
{
|
{
|
||||||
uv_fs_t request;
|
uv_fs_t request;
|
||||||
if (0 != uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL)) {
|
if (0 != uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL)) {
|
||||||
|
@ -55,26 +55,6 @@ describe 'os_unix function', ->
|
|||||||
it 'returns true if an arbitrary directory is given', ->
|
it 'returns true if an arbitrary directory is given', ->
|
||||||
eq TRUE, (mch_isdir 'unit-test-directory')
|
eq TRUE, (mch_isdir 'unit-test-directory')
|
||||||
|
|
||||||
describe 'is_executable', ->
|
|
||||||
is_executable = (name) ->
|
|
||||||
name = cstr (string.len name), name
|
|
||||||
os.is_executable name
|
|
||||||
|
|
||||||
it 'returns false when given a directory', ->
|
|
||||||
eq FALSE, (is_executable 'unit-test-directory')
|
|
||||||
|
|
||||||
it 'returns false when the given file does not exists', ->
|
|
||||||
eq FALSE, (is_executable 'does-not-exist.file')
|
|
||||||
|
|
||||||
it 'returns true when given an executable regular file', ->
|
|
||||||
eq TRUE, (is_executable absolute_executable)
|
|
||||||
|
|
||||||
it 'returns false when given a regular file without executable bit set', ->
|
|
||||||
-- This is a critical test since Windows does not have any executable
|
|
||||||
-- bit. Thus is_executable returns TRUE on every regular file on
|
|
||||||
-- Windows and this test will fail.
|
|
||||||
eq FALSE, (is_executable 'unit-test-directory/test.file')
|
|
||||||
|
|
||||||
describe 'mch_can_exe', ->
|
describe 'mch_can_exe', ->
|
||||||
mch_can_exe = (name) ->
|
mch_can_exe = (name) ->
|
||||||
name = cstr (string.len name), name
|
name = cstr (string.len name), name
|
||||||
@ -83,6 +63,9 @@ describe 'os_unix function', ->
|
|||||||
it 'returns false when given a directory', ->
|
it 'returns false when given a directory', ->
|
||||||
eq FALSE, (mch_can_exe './unit-test-directory')
|
eq FALSE, (mch_can_exe './unit-test-directory')
|
||||||
|
|
||||||
|
it 'returns false when given a regular file without executable bit set', ->
|
||||||
|
eq FALSE, (mch_can_exe 'unit-test-directory/test.file')
|
||||||
|
|
||||||
it 'returns false when the given file does not exists', ->
|
it 'returns false when the given file does not exists', ->
|
||||||
eq FALSE, (mch_can_exe 'does-not-exist.file')
|
eq FALSE, (mch_can_exe 'does-not-exist.file')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user