aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/file_perm_spec.lua42
-rw-r--r--test/functional/legacy/set_spec.lua15
-rw-r--r--test/functional/ui/highlight_spec.lua41
-rw-r--r--test/unit/os/fs_spec.lua19
4 files changed, 114 insertions, 3 deletions
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua
new file mode 100644
index 0000000000..cabeecdc9c
--- /dev/null
+++ b/test/functional/legacy/file_perm_spec.lua
@@ -0,0 +1,42 @@
+-- Test getting and setting file permissions.
+require('os')
+
+local helpers = require('test.functional.helpers')
+local clear, call, eq = helpers.clear, helpers.call, helpers.eq
+local neq, exc_exec = helpers.neq, helpers.exc_exec
+
+describe('Test getting and setting file permissions', function()
+ local tempfile = os.tmpname()
+
+ before_each(function()
+ os.remove(tempfile)
+ clear()
+ end)
+
+ it('file permissions', function()
+ eq('', call('getfperm', tempfile))
+ eq(0, call('setfperm', tempfile, 'r------'))
+
+ call('writefile', {'one'}, tempfile)
+ eq(9, call('len', call('getfperm', tempfile)))
+
+ eq(1, call('setfperm', tempfile, 'rwx------'))
+ if helpers.os_name == 'windows' then
+ eq('rw-rw-rw-', call('getfperm', tempfile))
+ else
+ eq('rwx------', call('getfperm', tempfile))
+ end
+
+ eq(1, call('setfperm', tempfile, 'r--r--r--'))
+ eq('r--r--r--', call('getfperm', tempfile))
+
+ local err = exc_exec(('call setfperm("%s", "---")'):format(tempfile))
+ neq(err:find('E475:'), nil)
+
+ eq(1, call('setfperm', tempfile, 'rwx------'))
+ end)
+
+ after_each(function()
+ os.remove(tempfile)
+ end)
+end)
diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua
index f81fcd3700..f2c907084e 100644
--- a/test/functional/legacy/set_spec.lua
+++ b/test/functional/legacy/set_spec.lua
@@ -7,6 +7,21 @@ local clear, execute, eval, eq =
describe(':set', function()
before_each(clear)
+ it('handles backslash properly', function()
+ execute('set iskeyword=a,b,c')
+ execute('set iskeyword+=d')
+ eq('a,b,c,d', eval('&iskeyword'))
+
+ execute([[set iskeyword+=\\,e]])
+ eq([[a,b,c,d,\,e]], eval('&iskeyword'))
+
+ execute('set iskeyword-=e')
+ eq([[a,b,c,d,\]], eval('&iskeyword'))
+
+ execute([[set iskeyword-=\]])
+ eq('a,b,c,d', eval('&iskeyword'))
+ end)
+
it('recognizes a trailing comma with +=', function()
execute('set wildignore=*.png,')
execute('set wildignore+=*.jpg')
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 0229b8bbf7..85fca4d7ca 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -302,6 +302,47 @@ describe('Default highlight groups', function()
{1:-- INSERT --} |
]], {[1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}})
end)
+ it('can be cleared by assigning NONE', function()
+ execute('syn keyword TmpKeyword neovim')
+ execute('hi link TmpKeyword ErrorMsg')
+ insert('neovim')
+ screen:expect([[
+ {1:neovi^m} |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], {
+ [1] = {foreground = Screen.colors.White, background = Screen.colors.Red}
+ })
+ execute("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE"
+ .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE")
+ screen:expect([[
+ neovi^m |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], {})
+ end)
end)
describe('guisp (special/undercurl)', function()
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 71b5e7f576..857a5001f1 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -14,6 +14,8 @@ local to_cstr = helpers.to_cstr
local OK = helpers.OK
local FAIL = helpers.FAIL
local NULL = helpers.NULL
+local NODE_NORMAL = 0
+local NODE_WRITABLE = 1
cimport('unistd.h')
cimport('./src/nvim/os/shell.h')
@@ -357,15 +359,12 @@ describe('fs function', function()
local function os_file_exists(filename)
return fs.os_file_exists((to_cstr(filename)))
end
-
local function os_rename(path, new_path)
return fs.os_rename((to_cstr(path)), (to_cstr(new_path)))
end
-
local function os_remove(path)
return fs.os_remove((to_cstr(path)))
end
-
local function os_open(path, flags, mode)
return fs.os_open((to_cstr(path)), flags, mode)
end
@@ -484,6 +483,20 @@ describe('fs function', function()
assert.is_true(0 <= (os_open(existing_file, ffi.C.kO_RDWR, 0)))
end)
end)
+
+ describe('os_nodetype', function()
+ before_each(function()
+ os.remove('non-existing-file')
+ end)
+
+ it('returns NODE_NORMAL for non-existing file', function()
+ eq(NODE_NORMAL, fs.os_nodetype(to_cstr('non-existing-file')))
+ end)
+
+ it('returns NODE_WRITABLE for /dev/stderr', function()
+ eq(NODE_WRITABLE, fs.os_nodetype(to_cstr('/dev/stderr')))
+ end)
+ end)
end)
describe('folder operations', function()