diff options
Diffstat (limited to 'test/functional')
| -rw-r--r-- | test/functional/ex_cmds/wviminfo_spec.lua | 11 | ||||
| -rw-r--r-- | test/functional/job/job_spec.lua | 16 | ||||
| -rw-r--r-- | test/functional/legacy/060_exists_and_has_functions_spec.lua | 8 | ||||
| -rw-r--r-- | test/functional/legacy/061_undo_tree_spec.lua | 15 | ||||
| -rw-r--r-- | test/functional/runtime/autoload/provider/python3_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/runtime/autoload/provider/python_spec.lua | 6 | 
6 files changed, 23 insertions, 39 deletions
| diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index 21176f1845..f4911cd3e8 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -1,7 +1,7 @@  local helpers, lfs = require('test.functional.helpers'), require('lfs') -local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait = -  helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.spawn, -  helpers.nvim_prog, helpers.set_session, helpers.wait +local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file +  = helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.spawn, +  helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file  describe(':wviminfo', function()    local viminfo_file = 'wviminfo_test' @@ -33,10 +33,7 @@ describe(':wviminfo', function()      local text = 'wviminfo test'      -- Create a dummy file -    local fp = io.open(viminfo_file, 'w') -    fp:write(text) -    fp:flush() -    fp:close() +    write_file(viminfo_file, text)      -- sanity check      eq(text, io.open(viminfo_file):read()) diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 1ba858251c..b60f9ff7a4 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -1,11 +1,11 @@  local helpers = require('test.functional.helpers') -local clear, nvim, eq, neq, ok, expect, eval, next_msg, run, stop, session -  = helpers.clear, helpers.nvim, helpers.eq, helpers.neq, helpers.ok, -  helpers.expect, helpers.eval, helpers.next_message, helpers.run, -  helpers.stop, helpers.session -local nvim_dir, insert, feed = helpers.nvim_dir, helpers.insert, helpers.feed -local source, execute, wait = helpers.source, helpers.execute, helpers.wait +local clear, eq, eval, execute, expect, feed, insert, neq, next_msg, nvim, +  nvim_dir, ok, run, session, source, stop, wait, write_file = helpers.clear, +  helpers.eq, helpers.eval, helpers.execute, helpers.expect, helpers.feed, +  helpers.insert, helpers.neq, helpers.next_message, helpers.nvim, +  helpers.nvim_dir, helpers.ok, helpers.run, helpers.session, helpers.source, +  helpers.stop, helpers.wait, helpers.write_file  describe('jobs', function() @@ -64,9 +64,7 @@ describe('jobs', function()    it('preserves NULs', function()      -- Make a file with NULs in it.      local filename = os.tmpname() -    local file = io.open(filename, "w") -    file:write("abc\0def\n") -    file:close() +    write_file(filename, "abc\0def\n")      nvim('command', "let j = jobstart(['cat', '"..filename.."'], g:job_opts)")      eq({'notification', 'stdout', {0, {'abc\ndef', ''}}}, next_msg()) diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua index d30f83dc6d..c4d2b01522 100644 --- a/test/functional/legacy/060_exists_and_has_functions_spec.lua +++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua @@ -3,6 +3,7 @@  local helpers = require('test.functional.helpers')  local feed, insert, source = helpers.feed, helpers.insert, helpers.source  local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local write_file = helpers.write_file  local os = require('os')  describe('exists() and has() functions', function() @@ -11,8 +12,7 @@ describe('exists() and has() functions', function()    it('is working', function()      -- Create a temporary script needed for the test. -    local script = io.open('test60.vim', 'w') -    script:write(helpers.dedent([=[ +    write_file('test60.vim', [=[        " Vim script for exists() function test        " Script-local variables are checked here @@ -110,9 +110,7 @@ describe('exists() and has() functions', function()            echo "FAILED"        endif        unlet str -      ]=])) -    script:flush() -    script:close() +      ]=])      source([=[        " Add the special directory with test scripts to &rtp diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua index c911e2be47..8cc2a371bb 100644 --- a/test/functional/legacy/061_undo_tree_spec.lua +++ b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,9 +1,10 @@  -- Tests for undo tree and :earlier and :later.  local helpers = require('test.functional.helpers') -local feed, insert, source, eq, eval, clear, execute, expect, wait = -  helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval, -  helpers.clear, helpers.execute, helpers.expect, helpers.wait +local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file +  = helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval, +  helpers.clear, helpers.execute, helpers.expect, helpers.wait, +  helpers.write_file  local function expect_empty_buffer()    -- The space will be removed by helpers.dedent but is needed because dedent @@ -13,12 +14,6 @@ end  local function expect_line(line)    return eq(line, eval('getline(".")'))  end -local function write_file(name, text) -  local file = io.open(name, 'w') -  file:write(text) -  file:flush() -  file:close() -end  describe('undo tree:', function()    before_each(clear) @@ -40,7 +35,7 @@ describe('undo tree:', function()        write_file('Xtest', '\n123456789\n')        -- `:earlier` and `:later` are (obviously) time-sensitive, so this test -      -- sometimes fails if the system is under load. It is wrapped in a local  +      -- sometimes fails if the system is under load. It is wrapped in a local        -- function to allow multiple attempts.        local function test_earlier_later()          clear() diff --git a/test/functional/runtime/autoload/provider/python3_spec.lua b/test/functional/runtime/autoload/provider/python3_spec.lua index 6e6ba96f81..43889b7b2a 100644 --- a/test/functional/runtime/autoload/provider/python3_spec.lua +++ b/test/functional/runtime/autoload/provider/python3_spec.lua @@ -11,7 +11,7 @@ end  local helpers = require('test.functional.helpers')  local eval, command, feed = helpers.eval, helpers.command, helpers.feed  local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert -local expect = helpers.expect +local expect, write_file = helpers.expect, helpers.write_file  describe('python3 commands and functions', function() @@ -46,9 +46,7 @@ describe('python3 commands and functions', function()    it('py3file', function()      local fname = 'py3file.py' -    local F = io.open(fname, 'w') -    F:write('vim.command("let set_by_py3file = 123")') -    F:close() +    write_file(fname, 'vim.command("let set_by_py3file = 123")')      command('py3file py3file.py')      eq(123, eval('g:set_by_py3file'))      os.remove(fname) diff --git a/test/functional/runtime/autoload/provider/python_spec.lua b/test/functional/runtime/autoload/provider/python_spec.lua index 5398d668bf..e71a7a4309 100644 --- a/test/functional/runtime/autoload/provider/python_spec.lua +++ b/test/functional/runtime/autoload/provider/python_spec.lua @@ -11,7 +11,7 @@ end  local helpers = require('test.functional.helpers')  local eval, command, feed = helpers.eval, helpers.command, helpers.feed  local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert -local expect = helpers.expect +local expect, write_file = helpers.expect, helpers.write_file  describe('python commands and functions', function() @@ -46,9 +46,7 @@ describe('python commands and functions', function()    it('pyfile', function()      local fname = 'pyfile.py' -    local F = io.open(fname, 'w') -    F:write('vim.command("let set_by_pyfile = 123")') -    F:close() +    write_file(fname, 'vim.command("let set_by_pyfile = 123")')      command('pyfile pyfile.py')      eq(123, eval('g:set_by_pyfile'))      os.remove(fname) | 
