From 330a6713bf888b1b612a1ebebb5d95bb0b31cd53 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 5 Aug 2019 10:25:49 +0200 Subject: [PATCH] test: Eliminate plugin/helpers.lua --- test/functional/plugin/health_spec.lua | 3 +- test/functional/plugin/helpers.lua | 41 ---------------------- test/functional/plugin/matchparen_spec.lua | 6 ++-- test/functional/plugin/msgpack_spec.lua | 8 ++--- test/functional/plugin/shada_spec.lua | 17 +++++++-- 5 files changed, 21 insertions(+), 54 deletions(-) delete mode 100644 test/functional/plugin/helpers.lua diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index f2d5e433db..3525e235de 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local plugin_helpers = require('test.functional.plugin.helpers') local clear = helpers.clear local curbuf_contents = helpers.curbuf_contents @@ -41,7 +40,7 @@ end) describe('health.vim', function() before_each(function() - plugin_helpers.reset() + clear{args={'-u', 'NORC'}} -- Provides functions: -- health#broken#check() -- health#success1#check() diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua deleted file mode 100644 index 4359380bd7..0000000000 --- a/test/functional/plugin/helpers.lua +++ /dev/null @@ -1,41 +0,0 @@ -local paths = require('test.config.paths') - -local helpers = require('test.functional.helpers')(nil) -local spawn, set_session, nvim_prog, merge_args = - helpers.spawn, helpers.set_session, helpers.nvim_prog, helpers.merge_args - -local additional_cmd = '' - -local function nvim_argv(shada_file) - local rtp_value = ('\'%s/runtime\''):format( - paths.test_source_path:gsub('\'', '\'\'')) - local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N', - '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', - '--cmd', 'let &runtimepath=' .. rtp_value, - '--cmd', additional_cmd, - '--embed', '--headless'} - if helpers.prepend_argv then - return merge_args(helpers.prepend_argv, nvim_args) - else - return nvim_args - end -end - -local session = nil - -local function reset(...) - if session then - session:close() - end - session = spawn(nvim_argv(...)) - set_session(session) -end - -local function set_additional_cmd(s) - additional_cmd = s -end - -return { - reset=reset, - set_additional_cmd=set_additional_cmd, -} diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua index 51ec7e4870..13e1283e2c 100644 --- a/test/functional/plugin/matchparen_spec.lua +++ b/test/functional/plugin/matchparen_spec.lua @@ -1,19 +1,17 @@ local helpers = require('test.functional.helpers')(after_each) -local plugin_helpers = require('test.functional.plugin.helpers') local Screen = require('test.functional.ui.screen') +local clear = helpers.clear local command = helpers.command local meths = helpers.meths local feed = helpers.feed local eq = helpers.eq -local reset = plugin_helpers.reset - describe('matchparen', function() local screen before_each(function() - reset() + clear{args={'-u', 'NORC'}} screen = Screen.new(20,5) screen:attach() screen:set_default_attr_ids( { diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua index 2ce9974812..d841cb8ce0 100644 --- a/test/functional/plugin/msgpack_spec.lua +++ b/test/functional/plugin/msgpack_spec.lua @@ -1,15 +1,15 @@ local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear local meths = helpers.meths local eq, nvim_eval, nvim_command, exc_exec = helpers.eq, helpers.eval, helpers.command, helpers.exc_exec local ok = helpers.ok local NIL = helpers.NIL -local plugin_helpers = require('test.functional.plugin.helpers') -local reset = plugin_helpers.reset - describe('autoload/msgpack.vim', function() - before_each(reset) + before_each(function() + clear{args={'-u', 'NORC'}} + end) local sp = function(typ, val) return ('{"_TYPE": v:msgpack_types.%s, "_VAL": %s}'):format(typ, val) diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua index 1482d83ee6..778dc4e219 100644 --- a/test/functional/plugin/shada_spec.lua +++ b/test/functional/plugin/shada_spec.lua @@ -1,4 +1,6 @@ +local paths = require('test.config.paths') local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf = helpers.eq, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec, helpers.funcs, helpers.feed, helpers.curbuf @@ -7,12 +9,21 @@ local read_file = helpers.read_file local mpack = require('mpack') -local plugin_helpers = require('test.functional.plugin.helpers') -local reset = plugin_helpers.reset - local shada_helpers = require('test.functional.shada.helpers') local get_shada_rw = shada_helpers.get_shada_rw +local function reset(shada_file) + -- TODO(justinmk): why is this needed? + local rtp_value = ('\'%s/runtime\''):format( + paths.test_source_path:gsub('\'', '\'\'')) + clear{args_rm={'-u', '-i'}, + args={'-u', 'NORC', + '-i', shada_file or 'NONE', + '--cmd', 'set laststatus&', + '--cmd', 'let &runtimepath='..rtp_value, + }} +end + local mpack_eq = function(expected, mpack_result) local mpack_keys = {'type', 'timestamp', 'length', 'value'}