aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada/errors_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-08-08 13:27:55 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 22:00:29 +0300
commit1542fc221e52f31d5102730a222b5dbbae782dcd (patch)
treea9de4e5f891d3c68da0319f10a02bb744313c401 /test/functional/shada/errors_spec.lua
parent1e067920994a5dd02df8f71f21afa29f0d4bcd21 (diff)
downloadrneovim-1542fc221e52f31d5102730a222b5dbbae782dcd.tar.gz
rneovim-1542fc221e52f31d5102730a222b5dbbae782dcd.tar.bz2
rneovim-1542fc221e52f31d5102730a222b5dbbae782dcd.zip
shada,functests: Improve detection of invalid ShaDa files
It appears that large portion of non-ShaDa ASCII text files may be parsed as a ShaDa file because it is mostly recognized as a sequence of unknown entries: all ASCII non-control characters are recognized as FIXUINT shada objects, so text like #!/bin/sh powerline "$@" 2>&1 | tee -a powerline (with trailing newline) will be recognized as a correct ShaDa file containing single unknown entry with type 0x23 (dec 35, '#'), timestamp 0x21 (dec 33, '!') and length 0x2F (dec 47, '/') without this commit. With it parsing this entry will fail.
Diffstat (limited to 'test/functional/shada/errors_spec.lua')
-rw-r--r--test/functional/shada/errors_spec.lua90
1 files changed, 86 insertions, 4 deletions
diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua
index e3a1dcdbb9..0dfb204b35 100644
--- a/test/functional/shada/errors_spec.lua
+++ b/test/functional/shada/errors_spec.lua
@@ -65,7 +65,7 @@ describe('ShaDa error handling', function()
it('fails on search pattern item with zero length', function()
wshada('\002\000\000')
- eq('Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 0', exc_exec(sdrcmd()))
+ eq('Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 3', exc_exec(sdrcmd()))
end)
it('fails on search pattern item with -2 timestamp', function()
@@ -95,12 +95,12 @@ describe('ShaDa error handling', function()
-- get MSGPACK_UNPACK_PARSE_ERROR and not MSGPACK_UNPACK_CONTINUE or
-- MSGPACK_UNPACK_EXTRA_BYTES.
wshada('\002\000\001\193')
- eq('Vim(rshada):E576: Failed to parse ShaDa file due to a msgpack parser error at position 0', exc_exec(sdrcmd()))
+ eq('Vim(rshada):E576: Failed to parse ShaDa file due to a msgpack parser error at position 3', exc_exec(sdrcmd()))
end)
it('fails on search pattern item with incomplete map', function()
wshada('\002\000\001\129')
- eq('Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 0', exc_exec(sdrcmd()))
+ eq('Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 3', exc_exec(sdrcmd()))
end)
it('fails on search pattern item without a pattern', function()
@@ -110,7 +110,7 @@ describe('ShaDa error handling', function()
it('fails on search pattern with extra bytes', function()
wshada('\002\000\002\128\000')
- eq('Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 0', exc_exec(sdrcmd()))
+ eq('Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3', exc_exec(sdrcmd()))
end)
it('fails on search pattern item with NIL value', function()
@@ -414,4 +414,86 @@ describe('ShaDa error handling', function()
wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161c\192')
eq('Vim(rshada):E575: Error while reading ShaDa file: buffer list entry entry at position 0 has c key value which is not an integer', exc_exec(sdrcmd()))
end)
+
+ it('fails on invalid ShaDa file (viminfo file)', function()
+ wshada([[# This viminfo file was generated by Vim 7.4.
+# You may edit it if you're careful!
+
+# Value of 'encoding' when this file was written
+*encoding=utf-8
+
+
+# hlsearch on (H) or off (h):
+~h
+# Last Search Pattern:
+~MSle0~/buffer=abuf
+
+# Last Substitute Search Pattern:
+~MSle0&^$
+
+# Last Substitute String:
+$
+
+# Command Line History (newest to oldest):
+:cq
+
+# Search String History (newest to oldest):
+? \<TMUX\>
+
+# Expression History (newest to oldest):
+=system('echo "\xAB"')
+
+# Input Line History (newest to oldest):
+@i
+
+# Input Line History (newest to oldest):
+
+# Registers:
+"0 LINE 0
+ case FLAG_B: puts("B"); break;
+"1 LINE 0
+ pick 874a489 shada,functests: Test compatibility support
+""- CHAR 0
+ .
+
+# global variables:
+!STUF_HISTORY_TRANSLIT LIS []
+!TR3_INPUT_HISTORY LIS []
+
+# File marks:
+'A 8320 12 ~/a.a/Proj/c/neovim-2076/src/nvim/ex_docmd.c
+'0 66 5 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+'1 7 0 ~/.vam/powerline/.git/MERGE_MSG
+'2 64 4 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+'3 9 0 ~/a.a/Proj/c/neovim/.git/COMMIT_EDITMSG
+'4 62 0 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+'5 57 4 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+'6 1 0 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+'7 399 7 /usr/share/vim/vim74/doc/motion.txt
+'8 1 0 ~/a.a/Proj/c/zpython/build/CMakeFiles/3.2.2/CMakeCCompiler.cmake
+'9 1 0 ~/a.a/Proj/c/vim/README.txt
+
+# Jumplist (newest first):
+-' 66 5 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+
+# History of marks within files (newest to oldest):
+
+> ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
+ " 66 5
+ ^ 66 6
+ . 66 5
+ + 65 0
+ + 65 0
+]])
+ eq('Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3', exc_exec(sdrcmd()))
+ eq('Vim(wshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3', exc_exec('wshada ' .. shada_fname))
+ eq(0, exc_exec('wshada! ' .. shada_fname))
+ end)
+
+ it('fails on invalid ShaDa file (wrapper script)', function()
+ wshada('#!/bin/sh\n\npowerline "$@" 2>&1 | tee -a powerline\n')
+ eq('Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3', exc_exec(sdrcmd()))
+ eq('Vim(wshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3', exc_exec('wshada ' .. shada_fname))
+ eq(0, exc_exec('wshada! ' .. shada_fname))
+ end)
end)