diff options
| author | Nicolas Hillegeer <nicolas@hillegeer.com> | 2014-04-28 14:17:06 +0200 |
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-28 16:17:25 -0300 |
| commit | 9e04e81ac7964dee43e24e5fa7b05ec7fc2b62e8 (patch) | |
| tree | 5f0bf642e48e9e835b052b6e5a5b795b5bf0b15e /test/unit/os | |
| parent | d699ccfb0c3500becfec9b02c24dc858d54c5a6e (diff) | |
| download | rneovim-9e04e81ac7964dee43e24e5fa7b05ec7fc2b62e8.tar.gz rneovim-9e04e81ac7964dee43e24e5fa7b05ec7fc2b62e8.tar.bz2 rneovim-9e04e81ac7964dee43e24e5fa7b05ec7fc2b62e8.zip | |
test: no longer define ad-hoc C headers
With the improved cimport helper, we can just load what we want.
Diffstat (limited to 'test/unit/os')
| -rw-r--r-- | test/unit/os/env.moon | 13 | ||||
| -rw-r--r-- | test/unit/os/fs.moon | 33 | ||||
| -rw-r--r-- | test/unit/os/users.moon | 18 |
3 files changed, 9 insertions, 55 deletions
diff --git a/test/unit/os/env.moon b/test/unit/os/env.moon index ad945f2206..4f2c45387e 100644 --- a/test/unit/os/env.moon +++ b/test/unit/os/env.moon @@ -1,16 +1,7 @@ {:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers' require 'lfs' --- fs = 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); -]] +env = cimport './src/os/os.h' NULL = ffi.cast 'void*', 0 @@ -86,7 +77,7 @@ describe 'env function', -> eq NULL, env.os_getenvname_at_index huge eq NULL, env.os_getenvname_at_index maxuint32 if ffi.abi '64bit' - -- couldn't use a bigger number because it gets converted to + -- couldn't use a bigger number because it gets converted to -- double somewere, should be big enough anyway -- maxuint64 = ffi.new 'size_t', 18446744073709551615 maxuint64 = ffi.new 'size_t', 18446744073709000000 diff --git a/test/unit/os/fs.moon b/test/unit/os/fs.moon index 1fc3022368..c1ab4bd78a 100644 --- a/test/unit/os/fs.moon +++ b/test/unit/os/fs.moon @@ -2,30 +2,11 @@ require 'lfs' require 'bit' --- 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 -{:OK, :FAIL} = lib +fs = cimport './src/os/os.h' + +-- TODO(aktau): define these constants "better" +FAIL = 0 +OK = 1 cppimport 'sys/stat.h' @@ -65,8 +46,6 @@ describe 'fs function', -> eq FAIL, (os_dirname buf, (len-1)) 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) -> directory = to_cstr directory fs.path_full_dir_name directory, buffer, len @@ -262,7 +241,7 @@ describe 'fs function', -> it 'fail if source file does not exist', -> eq FAIL, (os_rename not_exist, test) - + it 'can overwrite destination file if it exists', -> other = 'unit-test-directory/other.file' file = io.open other, 'w' diff --git a/test/unit/os/users.moon b/test/unit/os/users.moon index bfb52e50e6..261d1a8763 100644 --- a/test/unit/os/users.moon +++ b/test/unit/os/users.moon @@ -1,22 +1,6 @@ {:cimport, :internalize, :eq, :ffi, :lib, :cstr} = require 'test.unit.helpers' --- fs = cimport './src/os/os.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); -]] +users = cimport './src/os/os.h', 'unistd.h' NULL = ffi.cast 'void*', 0 OK = 1 |