mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
Use libuv errors instead of errno in unit tests
Replaced old unit tests for errno with libuv error codes UV_ENOENT and UV_EEXIST (for os_open and os_getperms). Added libuv include path to test/includes compiler calls - needed to get hold of libuv headers.
This commit is contained in:
parent
d54338f1e0
commit
28e59cb223
@ -8,6 +8,7 @@ foreach(hfile ${PRE_HEADERS})
|
|||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile}
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile}
|
||||||
COMMAND ${CMAKE_C_COMPILER} -std=c99 -E -P
|
COMMAND ${CMAKE_C_COMPILER} -std=c99 -E -P
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${hfile}
|
${CMAKE_CURRENT_SOURCE_DIR}/${hfile}
|
||||||
|
-I${LIBUV_INCLUDE_DIRS}
|
||||||
-o ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile})
|
-o ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile})
|
||||||
list(APPEND POST_HEADERS ${post_hfile})
|
list(APPEND POST_HEADERS ${post_hfile})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
#include <sys/errno.h>
|
|
||||||
|
|
||||||
static const int kENOENT = ENOENT;
|
|
||||||
static const int kEEXIST = EEXIST;
|
|
4
test/includes/pre/uv-errno.h
Normal file
4
test/includes/pre/uv-errno.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include <uv-errno.h>
|
||||||
|
|
||||||
|
static const int kUV_ENOENT = UV_ENOENT;
|
||||||
|
static const int kUV_EEXIST = UV_EEXIST;
|
@ -23,7 +23,7 @@ cimport('./src/nvim/fileio.h')
|
|||||||
local fs = cimport('./src/nvim/os/os.h')
|
local fs = cimport('./src/nvim/os/os.h')
|
||||||
cppimport('sys/stat.h')
|
cppimport('sys/stat.h')
|
||||||
cppimport('sys/fcntl.h')
|
cppimport('sys/fcntl.h')
|
||||||
cppimport('sys/errno.h')
|
cppimport('uv-errno.h')
|
||||||
|
|
||||||
local buffer = ""
|
local buffer = ""
|
||||||
local directory = nil
|
local directory = nil
|
||||||
@ -233,8 +233,8 @@ describe('fs function', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe('os_getperm', function()
|
describe('os_getperm', function()
|
||||||
it('returns -1 when the given file does not exist', function()
|
it('returns UV_ENOENT when the given file does not exist', function()
|
||||||
eq(-1, (os_getperm('non-existing-file')))
|
eq(ffi.C.UV_ENOENT, (os_getperm('non-existing-file')))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns a perm > 0 when given an existing file', function()
|
it('returns a perm > 0 when given an existing file', function()
|
||||||
@ -445,8 +445,8 @@ describe('fs function', function()
|
|||||||
local new_file = 'test_new_file'
|
local new_file = 'test_new_file'
|
||||||
local existing_file = 'unit-test-directory/test_existing.file'
|
local existing_file = 'unit-test-directory/test_existing.file'
|
||||||
|
|
||||||
it('returns -ENOENT for O_RDWR on a non-existing file', function()
|
it('returns UV_ENOENT for O_RDWR on a non-existing file', function()
|
||||||
eq(-ffi.C.kENOENT, (os_open('non-existing-file', ffi.C.kO_RDWR, 0)))
|
eq(ffi.C.UV_ENOENT, (os_open('non-existing-file', ffi.C.kO_RDWR, 0)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns non-negative for O_CREAT on a non-existing file', function()
|
it('returns non-negative for O_CREAT on a non-existing file', function()
|
||||||
@ -459,9 +459,9 @@ describe('fs function', function()
|
|||||||
assert.is_true(0 <= (os_open(existing_file, ffi.C.kO_CREAT, 0)))
|
assert.is_true(0 <= (os_open(existing_file, ffi.C.kO_CREAT, 0)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns -EEXIST for O_CREAT|O_EXCL on a existing file', function()
|
it('returns UV_EEXIST for O_CREAT|O_EXCL on a existing file', function()
|
||||||
assert_file_exists(existing_file)
|
assert_file_exists(existing_file)
|
||||||
eq(-ffi.C.kEEXIST, (os_open(existing_file, (bit.bor(ffi.C.kO_CREAT, ffi.C.kO_EXCL)), 0)))
|
eq(ffi.C.kUV_EEXIST, (os_open(existing_file, (bit.bor(ffi.C.kO_CREAT, ffi.C.kO_EXCL)), 0)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets `rwx` permissions for O_CREAT 700', function()
|
it('sets `rwx` permissions for O_CREAT 700', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user