diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-06-12 03:33:50 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-06-12 03:33:50 -0400 |
commit | 7a9377e720f078bda70c7d4e21f53d160d1e1b15 (patch) | |
tree | ba7961e6df8af043905c2aefd2cfabaad7975c53 | |
parent | e53dda90bdb66c78978f75a1eb209f7b601a74f0 (diff) | |
parent | 1f0830f7004c60f899fc169baecd68960f26ea70 (diff) | |
download | rneovim-7a9377e720f078bda70c7d4e21f53d160d1e1b15.tar.gz rneovim-7a9377e720f078bda70c7d4e21f53d160d1e1b15.tar.bz2 rneovim-7a9377e720f078bda70c7d4e21f53d160d1e1b15.zip |
Merge #2585 'Migrate legacy test 74.'
-rw-r--r-- | src/nvim/testdir/Makefile | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test74.in | 36 | ||||
-rw-r--r-- | src/nvim/testdir/test74.ok | 5 | ||||
-rw-r--r-- | test/functional/ex_cmds/wviminfo_spec.lua | 57 | ||||
-rw-r--r-- | test/functional/legacy/074_global_var_in_viminfo_spec.lua | 58 |
5 files changed, 116 insertions, 42 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index ffc5a38338..555d13df69 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -22,7 +22,7 @@ SCRIPTS := test_autoformat_join.out \ test57.out test58.out test59.out \ test61.out test62.out test63.out test64.out \ test68.out test69.out \ - test71.out test73.out test74.out \ + test71.out test73.out \ test79.out test80.out \ test83.out \ test86.out test87.out test88.out \ diff --git a/src/nvim/testdir/test74.in b/src/nvim/testdir/test74.in deleted file mode 100644 index 9fdbe771b3..0000000000 --- a/src/nvim/testdir/test74.in +++ /dev/null @@ -1,36 +0,0 @@ -" Tests for storing global variables in the .viminfo file vim: set ft=vim: - -STARTTEST -:so small.vim -:" Do all test in a separate window to avoid E211 when we recursively -:" delete the Xfind directory during cleanup -:" -:" This will cause a few errors, do it silently. -:set visualbell -:set viminfo+=! -:let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000} -:" store a really long list, so line wrapping will occur in viminfo file -:let MY_GLOBAL_LIST=range(1,100) -:wv! Xviminfo -:unlet MY_GLOBAL_DICT -:unlet MY_GLOBAL_LIST -:rv! Xviminfo -:call delete('Xviminfo') -:if exists("MY_GLOBAL_DICT") -:redir >> test.out -:echo MY_GLOBAL_DICT -:redir end -:endif -:if exists("MY_GLOBAL_LIST") -:redir >> test.out -:echo MY_GLOBAL_LIST -:redir end -:endif -:redir >> test.out -:echo "foobar" -:redir end -:endif -:qa! -ENDTEST - -eof diff --git a/src/nvim/testdir/test74.ok b/src/nvim/testdir/test74.ok deleted file mode 100644 index b026c33c35..0000000000 --- a/src/nvim/testdir/test74.ok +++ /dev/null @@ -1,5 +0,0 @@ - -{'foo': 1, 'longvarible': 1000, 'bar': 0} -[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] - -foobar diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua new file mode 100644 index 0000000000..21176f1845 --- /dev/null +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -0,0 +1,57 @@ +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 + +describe(':wviminfo', function() + local viminfo_file = 'wviminfo_test' + local session + + before_each(function() + if session then + session:exit(0) + end + + -- Override the default session because we need 'swapfile' for these tests. + local session = spawn({nvim_prog, '-u', 'NONE', '--embed', + '--cmd', 'set swapfile'}) + set_session(session) + + os.remove(viminfo_file) + end) + + it('creates a viminfo file', function() + -- file should _not_ exist + eq(nil, lfs.attributes(viminfo_file)) + execute('wv! '..viminfo_file) + wait() + -- file _should_ exist + neq(nil, lfs.attributes(viminfo_file)) + end) + + it('overwrites existing files', function() + local text = 'wviminfo test' + + -- Create a dummy file + local fp = io.open(viminfo_file, 'w') + fp:write(text) + fp:flush() + fp:close() + + -- sanity check + eq(text, io.open(viminfo_file):read()) + neq(nil, lfs.attributes(viminfo_file)) + + execute('wv! '..viminfo_file) + wait() + + -- File should have been overwritten with a viminfo file. + local line1 = io.lines(viminfo_file)() + assert(nil ~= string.find(line1, 'This viminfo file was generated by Nvim'), + viminfo_file..' should be a viminfo-formatted file') + end) + + teardown(function() + os.remove(viminfo_file) + end) +end) diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua new file mode 100644 index 0000000000..180071118a --- /dev/null +++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -0,0 +1,58 @@ +-- Tests for storing global variables in the .viminfo file + +local helpers, lfs = require('test.functional.helpers'), require('lfs') +local clear, execute, eq, neq, eval, wait, spawn = + helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.eval, + helpers.wait, helpers.spawn + +describe('storing global variables in viminfo files', function() + setup(function() + clear() + os.remove("Xviminfo") + end) + + it('is working', function() + local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '--embed'}) + helpers.set_session(nvim2) + + local test_dict = {foo = 1, bar = 0, longvarible = 1000} + local test_list = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100} + + execute( + -- This will cause a few errors, do it silently. + 'set visualbell', + 'set viminfo+=!', + "let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}", + -- Store a really long list, so line wrapping will occur in viminfo + -- file. + 'let MY_GLOBAL_LIST=range(1,100)' + ) + eq(test_dict, eval('MY_GLOBAL_DICT')) + eq(test_list, eval('MY_GLOBAL_LIST')) + + execute('wv! Xviminfo') + wait() + + -- Assert that the viminfo file exists. + neq(nil, lfs.attributes('Xviminfo')) + execute('unlet MY_GLOBAL_DICT', + 'unlet MY_GLOBAL_LIST') + -- Assert that the variables where deleted. + eq(0, eval('exists("MY_GLOBAL_DICT")')) + eq(0, eval('exists("MY_GLOBAL_LIST")')) + + execute('rv! Xviminfo') + + eq(test_list, eval('MY_GLOBAL_LIST')) + eq(test_dict, eval('MY_GLOBAL_DICT')) + end) + + teardown(function() + os.remove('Xviminfo') + end) +end) |