mirror of
https://github.com/neovim/neovim.git
synced 2025-11-08 11:35:10 +00:00
test: no longer define ad-hoc C headers
With the improved cimport helper, we can just load what we want.
This commit is contained in:
committed by
Thiago de Arruda
parent
d699ccfb0c
commit
9e04e81ac7
@@ -1,16 +1,7 @@
|
|||||||
{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
|
{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
|
||||||
require 'lfs'
|
require 'lfs'
|
||||||
|
|
||||||
-- fs = cimport './src/os/os.h'
|
env = cimport './src/os/os.h'
|
||||||
-- remove these statements once 'cimport' is working properly for misc1.h
|
|
||||||
env = lib
|
|
||||||
ffi.cdef [[
|
|
||||||
const char *os_getenv(const char *name);
|
|
||||||
int os_setenv(const char *name, const char *value, int override);
|
|
||||||
char *os_getenvname_at_index(size_t index);
|
|
||||||
long os_get_pid(void);
|
|
||||||
void os_get_hostname(char *hostname, size_t len);
|
|
||||||
]]
|
|
||||||
|
|
||||||
NULL = ffi.cast 'void*', 0
|
NULL = ffi.cast 'void*', 0
|
||||||
|
|
||||||
|
|||||||
@@ -2,30 +2,11 @@
|
|||||||
require 'lfs'
|
require 'lfs'
|
||||||
require 'bit'
|
require 'bit'
|
||||||
|
|
||||||
-- fs = cimport './src/os/os.h'
|
fs = cimport './src/os/os.h'
|
||||||
-- remove these statements once 'cimport' is working properly for misc1.h
|
|
||||||
fs = lib
|
|
||||||
ffi.cdef [[
|
|
||||||
enum OKFAIL {
|
|
||||||
OK = 1, FAIL = 0
|
|
||||||
};
|
|
||||||
int os_dirname(char_u *buf, int len);
|
|
||||||
bool os_isdir(char_u * name);
|
|
||||||
bool is_executable(char_u *name);
|
|
||||||
bool os_can_exe(char_u *name);
|
|
||||||
int32_t os_getperm(char_u *name);
|
|
||||||
int os_setperm(char_u *name, long perm);
|
|
||||||
bool os_file_exists(const char_u *name);
|
|
||||||
bool os_file_is_readonly(char *fname);
|
|
||||||
int os_file_is_writable(const char *name);
|
|
||||||
int os_rename(const char_u *path, const char_u *new_path);
|
|
||||||
int os_mkdir(const char *path, int32_t mode);
|
|
||||||
int os_rmdir(const char *path);
|
|
||||||
int os_remove(const char *path);
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- import constants parsed by ffi
|
-- TODO(aktau): define these constants "better"
|
||||||
{:OK, :FAIL} = lib
|
FAIL = 0
|
||||||
|
OK = 1
|
||||||
|
|
||||||
cppimport 'sys/stat.h'
|
cppimport 'sys/stat.h'
|
||||||
|
|
||||||
@@ -65,8 +46,6 @@ describe 'fs function', ->
|
|||||||
eq FAIL, (os_dirname buf, (len-1))
|
eq FAIL, (os_dirname buf, (len-1))
|
||||||
|
|
||||||
describe 'path_full_dir_name', ->
|
describe 'path_full_dir_name', ->
|
||||||
ffi.cdef 'int path_full_dir_name(char *directory, char *buffer, int len);'
|
|
||||||
|
|
||||||
path_full_dir_name = (directory, buffer, len) ->
|
path_full_dir_name = (directory, buffer, len) ->
|
||||||
directory = to_cstr directory
|
directory = to_cstr directory
|
||||||
fs.path_full_dir_name directory, buffer, len
|
fs.path_full_dir_name directory, buffer, len
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
{:cimport, :internalize, :eq, :ffi, :lib, :cstr} = require 'test.unit.helpers'
|
{:cimport, :internalize, :eq, :ffi, :lib, :cstr} = require 'test.unit.helpers'
|
||||||
|
|
||||||
-- fs = cimport './src/os/os.h'
|
users = cimport './src/os/os.h', 'unistd.h'
|
||||||
-- remove these statements once 'cimport' is working properly for misc1.h
|
|
||||||
users = lib
|
|
||||||
ffi.cdef [[
|
|
||||||
typedef struct growarray {
|
|
||||||
int ga_len;
|
|
||||||
int ga_maxlen;
|
|
||||||
int ga_itemsize;
|
|
||||||
int ga_growsize;
|
|
||||||
void *ga_data;
|
|
||||||
} garray_T;
|
|
||||||
int os_get_usernames(garray_T *usernames);
|
|
||||||
int os_get_user_name(char *s, size_t len);
|
|
||||||
int os_get_uname(int uid, char *s, size_t len);
|
|
||||||
char *os_get_user_directory(const char *name);
|
|
||||||
int getuid(void);
|
|
||||||
]]
|
|
||||||
|
|
||||||
NULL = ffi.cast 'void*', 0
|
NULL = ffi.cast 'void*', 0
|
||||||
OK = 1
|
OK = 1
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
|
{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
|
||||||
require 'lfs'
|
require 'lfs'
|
||||||
|
|
||||||
path = lib
|
path = cimport './src/path.h'
|
||||||
|
|
||||||
ffi.cdef [[
|
|
||||||
typedef enum file_comparison {
|
|
||||||
kEqualFiles = 1, kDifferentFiles = 2, kBothFilesMissing = 4, kOneFileMissing = 6, kEqualFileNames = 7
|
|
||||||
} FileComparison;
|
|
||||||
FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
|
|
||||||
char_u *path_tail(char_u *fname);
|
|
||||||
char_u *path_tail_with_sep(char_u *fname);
|
|
||||||
char_u *path_next_component(char_u *fname);
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- import constants parsed by ffi
|
-- import constants parsed by ffi
|
||||||
{:kEqualFiles, :kDifferentFiles, :kBothFilesMissing, :kOneFileMissing, :kEqualFileNames} = path
|
{:kEqualFiles, :kDifferentFiles, :kBothFilesMissing, :kOneFileMissing, :kEqualFileNames} = path
|
||||||
@@ -120,8 +110,6 @@ describe 'more path function', ->
|
|||||||
lfs.rmdir 'unit-test-directory'
|
lfs.rmdir 'unit-test-directory'
|
||||||
|
|
||||||
describe 'vim_FullName', ->
|
describe 'vim_FullName', ->
|
||||||
ffi.cdef 'int vim_FullName(char *fname, char *buf, int len, int force);'
|
|
||||||
|
|
||||||
vim_FullName = (filename, buffer, length, force) ->
|
vim_FullName = (filename, buffer, length, force) ->
|
||||||
filename = to_cstr filename
|
filename = to_cstr filename
|
||||||
path.vim_FullName filename, buffer, length, force
|
path.vim_FullName filename, buffer, length, force
|
||||||
@@ -209,8 +197,6 @@ describe 'more path function', ->
|
|||||||
eq OK, result
|
eq OK, result
|
||||||
|
|
||||||
describe 'append_path', ->
|
describe 'append_path', ->
|
||||||
ffi.cdef 'int append_path(char *path, char *to_append, int max_len);'
|
|
||||||
|
|
||||||
it 'joins given paths with a slash', ->
|
it 'joins given paths with a slash', ->
|
||||||
path1 = cstr 100, 'path1'
|
path1 = cstr 100, 'path1'
|
||||||
to_append = to_cstr 'path2'
|
to_append = to_cstr 'path2'
|
||||||
@@ -247,8 +233,6 @@ describe 'more path function', ->
|
|||||||
eq '/path2', (ffi.string path1)
|
eq '/path2', (ffi.string path1)
|
||||||
|
|
||||||
describe 'path_is_absolute_path', ->
|
describe 'path_is_absolute_path', ->
|
||||||
ffi.cdef 'int path_is_absolute_path(char *fname);'
|
|
||||||
|
|
||||||
path_is_absolute_path = (filename) ->
|
path_is_absolute_path = (filename) ->
|
||||||
filename = to_cstr filename
|
filename = to_cstr filename
|
||||||
path.path_is_absolute_path filename
|
path.path_is_absolute_path filename
|
||||||
|
|||||||
Reference in New Issue
Block a user