aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/eval/let_spec.lua22
-rw-r--r--test/functional/helpers.lua6
-rw-r--r--test/functional/legacy/arglist_spec.lua4
-rw-r--r--test/helpers.lua104
-rw-r--r--test/unit/preprocess.lua25
5 files changed, 159 insertions, 2 deletions
diff --git a/test/functional/eval/let_spec.lua b/test/functional/eval/let_spec.lua
new file mode 100644
index 0000000000..c3ab3cc367
--- /dev/null
+++ b/test/functional/eval/let_spec.lua
@@ -0,0 +1,22 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local eq = helpers.eq
+local clear = helpers.clear
+local meths = helpers.meths
+local redir_exec = helpers.redir_exec
+
+before_each(clear)
+
+describe(':let command', function()
+ it('correctly lists variables with curly-braces', function()
+ meths.set_var('v', {0})
+ eq('\nv [0]', redir_exec('let {"v"}'))
+ end)
+
+ it('correctly lists variables with subscript', function()
+ meths.set_var('v', {0})
+ eq('\nv[0] #0', redir_exec('let v[0]'))
+ eq('\ng:["v"][0] #0', redir_exec('let g:["v"][0]'))
+ eq('\n{"g:"}["v"][0] #0', redir_exec('let {"g:"}["v"][0]'))
+ end)
+end)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 4db658d98c..53cbf8d4a1 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -9,6 +9,7 @@ local TcpStream = require('nvim.tcp_stream')
local SocketStream = require('nvim.socket_stream')
local ChildProcessStream = require('nvim.child_process_stream')
+local check_cores = global_helpers.check_cores
local check_logs = global_helpers.check_logs
local neq = global_helpers.neq
local eq = global_helpers.eq
@@ -608,7 +609,10 @@ local M = {
return function(after_each)
if after_each then
- after_each(check_logs)
+ after_each(function()
+ check_logs()
+ check_cores('build/bin/nvim')
+ end)
end
return M
end
diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua
index b86d3f0aea..f5e3522972 100644
--- a/test/functional/legacy/arglist_spec.lua
+++ b/test/functional/legacy/arglist_spec.lua
@@ -222,7 +222,6 @@ describe('argument list commands', function()
execute('argedit a')
eq({'a', 'b'}, eval('argv()'))
eq('a', eval('expand("%:t")'))
- assert_fails('argedit a b', 'E172:')
execute('argedit c')
eq({'a', 'c', 'b'}, eval('argv()'))
execute('0argedit x')
@@ -232,6 +231,9 @@ describe('argument list commands', function()
execute('argedit! y')
eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()'))
execute('%argd')
+ -- Nvim allows unescaped spaces in filename on all platforms. #6010
+ execute('argedit a b')
+ eq({'a b'}, eval('argv()'))
end)
it('test for :argdelete command', function()
diff --git a/test/helpers.lua b/test/helpers.lua
index 3f7a9c2b74..1e01aaa098 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -17,6 +17,34 @@ local ok = function(res)
return assert.is_true(res)
end
+local function glob(initial_path, re, exc_re)
+ local paths_to_check = {initial_path}
+ local ret = {}
+ local checked_files = {}
+ while #paths_to_check > 0 do
+ local cur_path = paths_to_check[#paths_to_check]
+ paths_to_check[#paths_to_check] = nil
+ for e in lfs.dir(cur_path) do
+ local full_path = cur_path .. '/' .. e
+ local checked_path = full_path:sub(#initial_path + 1)
+ if ((not exc_re or not checked_path:match(exc_re))
+ and e:sub(1, 1) ~= '.') then
+ local attrs = lfs.attributes(full_path)
+ local check_key = attrs.dev .. ':' .. tostring(attrs.ino)
+ if not checked_files[check_key] then
+ checked_files[check_key] = true
+ if attrs.mode == 'directory' then
+ paths_to_check[#paths_to_check + 1] = full_path
+ elseif not re or checked_path:match(re) then
+ ret[#ret + 1] = full_path
+ end
+ end
+ end
+ end
+ end
+ return ret
+end
+
local function check_logs()
local log_dir = os.getenv('LOG_DIR')
local runtime_errors = 0
@@ -109,6 +137,79 @@ local function filter(filter_func, tab)
return rettab
end
+local function hasenv(name)
+ local env = os.getenv(name)
+ if env and env ~= '' then
+ return env
+ end
+ return nil
+end
+
+local tests_skipped = 0
+
+local function check_cores(app)
+ app = app or 'build/bin/nvim'
+ local initial_path, re, exc_re
+ local gdb_db_cmd = 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
+ local lldb_db_cmd = 'lldb -Q -o "bt all" -f "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
+ local random_skip = false
+ local db_cmd
+ if hasenv('NVIM_TEST_CORE_GLOB_DIRECTORY') then
+ initial_path = os.getenv('NVIM_TEST_CORE_GLOB_DIRECTORY')
+ re = os.getenv('NVIM_TEST_CORE_GLOB_RE')
+ exc_re = os.getenv('NVIM_TEST_CORE_EXC_RE')
+ db_cmd = os.getenv('NVIM_TEST_CORE_DB_CMD') or gdb_db_cmd
+ random_skip = os.getenv('NVIM_TEST_CORE_RANDOM_SKIP')
+ elseif os.getenv('TRAVIS_OS_NAME') == 'osx' then
+ initial_path = '/cores'
+ re = nil
+ exc_re = nil
+ db_cmd = lldb_db_cmd
+ else
+ initial_path = '.'
+ re = '/core[^/]*$'
+ exc_re = '^/%.deps$'
+ db_cmd = gdb_db_cmd
+ random_skip = true
+ end
+ -- Finding cores takes too much time on linux
+ if random_skip and math.random() < 0.9 then
+ tests_skipped = tests_skipped + 1
+ return
+ end
+ local cores = glob(initial_path, re, exc_re)
+ local found_cores = 0
+ local out = io.stdout
+ for _, core in ipairs(cores) do
+ local len = 80 - #core - #('Core file ') - 2
+ local esigns = ('='):rep(len / 2)
+ out:write(('\n%s Core file %s %s\n'):format(esigns, core, esigns))
+ out:flush()
+ local pipe = io.popen(
+ db_cmd:gsub('%$_NVIM_TEST_APP', app):gsub('%$_NVIM_TEST_CORE', core)
+ .. ' 2>&1', 'r')
+ if pipe then
+ local bt = pipe:read('*a')
+ if bt then
+ out:write(bt)
+ out:write('\n')
+ else
+ out:write('Failed to read from the pipe\n')
+ end
+ else
+ out:write('Failed to create pipe\n')
+ end
+ out:flush()
+ found_cores = found_cores + 1
+ os.remove(core)
+ end
+ if found_cores ~= 0 then
+ out:write(('\nTests covered by this check: %u\n'):format(tests_skipped + 1))
+ end
+ tests_skipped = 0
+ assert(0 == found_cores)
+end
+
return {
eq = eq,
neq = neq,
@@ -118,4 +219,7 @@ return {
tmpname = tmpname,
map = map,
filter = filter,
+ glob = glob,
+ check_cores = check_cores,
+ hasenv = hasenv,
}
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
index 1c9b290462..4d819e5f23 100644
--- a/test/unit/preprocess.lua
+++ b/test/unit/preprocess.lua
@@ -185,6 +185,30 @@ local function repeated_call(...)
return nil
end
+function Gcc:filter_standard_defines(defines)
+ if not self.standard_defines then
+ local pseudoheader_fname = 'tmp_empty_pseudoheader.h'
+ local pseudoheader_file = io.open(pseudoheader_fname, 'w')
+ pseudoheader_file:close()
+ local standard_defines = repeated_call(self.path,
+ self.preprocessor_extra_flags,
+ self.get_defines_extra_flags,
+ {pseudoheader_fname})
+ os.remove(pseudoheader_fname)
+ self.standard_defines = {}
+ for line in standard_defines:gmatch('[^\n]+') do
+ self.standard_defines[line] = true
+ end
+ end
+ local ret = {}
+ for line in defines:gmatch('[^\n]+') do
+ if not self.standard_defines[line] then
+ ret[#ret + 1] = line
+ end
+ end
+ return table.concat(ret, "\n")
+end
+
-- returns a stream representing a preprocessed form of the passed-in headers.
-- Don't forget to close the stream by calling the close() method on it.
function Gcc:preprocess(previous_defines, ...)
@@ -201,6 +225,7 @@ function Gcc:preprocess(previous_defines, ...)
local defines = repeated_call(self.path, self.preprocessor_extra_flags,
self.get_defines_extra_flags,
{pseudoheader_fname})
+ defines = self:filter_standard_defines(defines)
-- lfs = require("lfs")
-- print("CWD: #{lfs.currentdir!}")