errors_spec.lua 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. -- ShaDa errors handling support
  2. local t = require('test.testutil')
  3. local n = require('test.functional.testnvim')()
  4. local t_shada = require('test.functional.shada.testutil')
  5. local nvim_command, eq, exc_exec = n.command, t.eq, n.exc_exec
  6. local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw
  7. local wshada, sdrcmd, shada_fname, clean = get_shada_rw('Xtest-functional-shada-errors.shada')
  8. describe('ShaDa error handling', function()
  9. before_each(reset)
  10. after_each(function()
  11. clear()
  12. clean()
  13. end)
  14. -- Note: most of tests have additional items like sX, mX, rX. These are for
  15. -- valgrind tests, to check for memory leaks (i.e. whether error handling code
  16. -- does (not) forget to call ga_clear). Not needed for array-based items like
  17. -- history because they are not using ad_ga.
  18. it('does not fail on empty file', function()
  19. wshada('')
  20. eq(0, exc_exec(sdrcmd()))
  21. end)
  22. it('fails on zero', function()
  23. wshada('\000')
  24. eq(
  25. 'Vim(rshada):E576: Error while reading ShaDa file: expected positive integer at position 1, but got nothing',
  26. exc_exec(sdrcmd())
  27. )
  28. end)
  29. it('fails on missing item', function()
  30. wshada('\000\000\000')
  31. eq(
  32. 'Vim(rshada):E576: Error while reading ShaDa file: there is an item at position 0 that must not be there: Missing items are for internal uses only',
  33. exc_exec(sdrcmd())
  34. )
  35. end)
  36. it('fails on -2 type', function()
  37. wshada('\254\000\000')
  38. eq(
  39. 'Vim(rshada):E576: Error while reading ShaDa file: expected positive integer at position 0',
  40. exc_exec(sdrcmd())
  41. )
  42. end)
  43. it('does not fail on header with zero length', function()
  44. -- Header items are skipped when reading.
  45. wshada('\001\000\000')
  46. eq(0, exc_exec(sdrcmd()))
  47. end)
  48. it('fails on search pattern item with zero length', function()
  49. wshada('\002\000\000')
  50. eq(
  51. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
  52. exc_exec(sdrcmd())
  53. )
  54. end)
  55. it('fails on search pattern item with -2 timestamp', function()
  56. wshada('\002\254\000')
  57. eq(
  58. 'Vim(rshada):E576: Error while reading ShaDa file: expected positive integer at position 1',
  59. exc_exec(sdrcmd())
  60. )
  61. end)
  62. it('fails on search pattern item with -2 length', function()
  63. wshada('\002\000\254')
  64. eq(
  65. 'Vim(rshada):E576: Error while reading ShaDa file: expected positive integer at position 2',
  66. exc_exec(sdrcmd())
  67. )
  68. end)
  69. it('fails on search pattern item with length greater then file length', function()
  70. wshada('\002\000\002\000')
  71. eq(
  72. 'Vim(rshada):E576: Error while reading ShaDa file: last entry specified that it occupies 2 bytes, but file ended earlier',
  73. exc_exec(sdrcmd())
  74. )
  75. end)
  76. it('fails on search pattern item with invalid byte', function()
  77. -- 195 (== 0xC1) cannot start any valid messagepack entry (the only byte
  78. -- that cannot do this)
  79. wshada('\002\000\001\193')
  80. eq(
  81. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
  82. exc_exec(sdrcmd())
  83. )
  84. end)
  85. it('fails on search pattern item with incomplete map', function()
  86. wshada('\002\000\001\129')
  87. eq(
  88. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has key value which is not a string',
  89. exc_exec(sdrcmd())
  90. )
  91. end)
  92. it('fails on search pattern item without a pattern', function()
  93. wshada('\002\000\005\129\162sX\192')
  94. eq(
  95. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has no pattern',
  96. exc_exec(sdrcmd())
  97. )
  98. end)
  99. it('fails on search pattern with extra bytes', function()
  100. wshada('\002\000\002\128\000')
  101. eq(
  102. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has no pattern',
  103. exc_exec(sdrcmd())
  104. )
  105. end)
  106. it('fails on search pattern item with NIL value', function()
  107. wshada('\002\000\001\192')
  108. eq(
  109. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
  110. exc_exec(sdrcmd())
  111. )
  112. end)
  113. -- sp entry is here because it causes an allocation.
  114. it('fails on search pattern item with empty key', function()
  115. wshada('\002\000\013\131\162sp\196\001a\162sX\192\160\000')
  116. eq(
  117. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has empty key',
  118. exc_exec(sdrcmd())
  119. )
  120. end)
  121. it('fails on search pattern item with NIL magic key value', function()
  122. wshada('\002\000\009\130\162sX\192\162sm\192')
  123. eq(
  124. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sm key value which is not a boolean',
  125. exc_exec(sdrcmd())
  126. )
  127. end)
  128. it('fails on search pattern item with NIL smartcase key value', function()
  129. wshada('\002\000\009\130\162sX\192\162sc\192')
  130. eq(
  131. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sc key value which is not a boolean',
  132. exc_exec(sdrcmd())
  133. )
  134. end)
  135. it('fails on search pattern item with NIL search_backward key value', function()
  136. wshada('\002\000\009\130\162sX\192\162sb\192')
  137. eq(
  138. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sb key value which is not a boolean',
  139. exc_exec(sdrcmd())
  140. )
  141. end)
  142. it('fails on search pattern item with NIL has_line_offset key value', function()
  143. wshada('\002\000\009\130\162sX\192\162sl\192')
  144. eq(
  145. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sl key value which is not a boolean',
  146. exc_exec(sdrcmd())
  147. )
  148. end)
  149. it('fails on search pattern item with NIL place_cursor_at_end key value', function()
  150. wshada('\002\000\009\130\162sX\192\162se\192')
  151. eq(
  152. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has se key value which is not a boolean',
  153. exc_exec(sdrcmd())
  154. )
  155. end)
  156. it('fails on search pattern item with NIL is_last_used key value', function()
  157. wshada('\002\000\009\130\162sX\192\162su\192')
  158. eq(
  159. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has su key value which is not a boolean',
  160. exc_exec(sdrcmd())
  161. )
  162. end)
  163. it('fails on search pattern item with NIL is_substitute_pattern key value', function()
  164. wshada('\002\000\009\130\162sX\192\162ss\192')
  165. eq(
  166. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has ss key value which is not a boolean',
  167. exc_exec(sdrcmd())
  168. )
  169. end)
  170. it('fails on search pattern item with NIL highlighted key value', function()
  171. wshada('\002\000\009\130\162sX\192\162sh\192')
  172. eq(
  173. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sh key value which is not a boolean',
  174. exc_exec(sdrcmd())
  175. )
  176. end)
  177. it('fails on search pattern item with NIL offset key value', function()
  178. wshada('\002\000\009\130\162sX\192\162so\192')
  179. eq(
  180. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has so key value which is not an integer',
  181. exc_exec(sdrcmd())
  182. )
  183. end)
  184. it('fails on search pattern item with NIL pat key value', function()
  185. wshada('\002\000\009\130\162sX\192\162sp\192')
  186. eq(
  187. 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sp key value which is not a binary',
  188. exc_exec(sdrcmd())
  189. )
  190. end)
  191. for _, v in ipairs({
  192. { name = 'global mark', mpack = '\007' },
  193. { name = 'jump', mpack = '\008' },
  194. { name = 'local mark', mpack = '\010' },
  195. { name = 'change', mpack = '\011' },
  196. }) do
  197. it('fails on ' .. v.name .. ' item with NIL value', function()
  198. wshada(v.mpack .. '\000\001\192')
  199. eq(
  200. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 is not a dict',
  201. exc_exec(sdrcmd())
  202. )
  203. end)
  204. -- f entry is here because it causes an allocation.
  205. it('fails on ' .. v.name .. ' item with empty key', function()
  206. wshada(v.mpack .. '\000\012\131\161f\196\001/\162mX\192\160\000')
  207. eq(
  208. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has empty key',
  209. exc_exec(sdrcmd())
  210. )
  211. end)
  212. it('fails on ' .. v.name .. ' item without f key', function()
  213. wshada(v.mpack .. '\000\008\130\162mX\192\161l\001')
  214. eq(
  215. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 is missing file name',
  216. exc_exec(sdrcmd())
  217. )
  218. end)
  219. it('fails on ' .. v.name .. ' item with zero l key', function()
  220. wshada(v.mpack .. '\000\013\131\162mX\192\161f\196\001/\161l\000')
  221. eq(
  222. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has invalid line number',
  223. exc_exec(sdrcmd())
  224. )
  225. end)
  226. it('fails on ' .. v.name .. ' item with negative l key', function()
  227. wshada(v.mpack .. '\000\013\131\162mX\192\161f\196\001/\161l\255')
  228. eq(
  229. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has invalid line number',
  230. exc_exec(sdrcmd())
  231. )
  232. end)
  233. it('fails on ' .. v.name .. ' item with negative c key', function()
  234. wshada(v.mpack .. '\000\013\131\162mX\192\161f\196\001/\161c\255')
  235. eq(
  236. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has invalid column number',
  237. exc_exec(sdrcmd())
  238. )
  239. end)
  240. it('fails on ' .. v.name .. ' item with STR n key value', function()
  241. wshada(v.mpack .. '\000\011\130\162mX\192\161n\163spa')
  242. eq(
  243. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has n key value which is not an integer',
  244. exc_exec(sdrcmd())
  245. )
  246. end)
  247. it('fails on ' .. v.name .. ' item with STR l key value', function()
  248. wshada(v.mpack .. '\000\010\130\162mX\192\161l\162sp')
  249. eq(
  250. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has l key value which is not an integer',
  251. exc_exec(sdrcmd())
  252. )
  253. end)
  254. it('fails on ' .. v.name .. ' item with STR c key value', function()
  255. wshada(v.mpack .. '\000\010\130\162mX\192\161c\162sp')
  256. eq(
  257. 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has c key value which is not an integer',
  258. exc_exec(sdrcmd())
  259. )
  260. end)
  261. end
  262. it('fails on register item with NIL value', function()
  263. wshada('\005\000\001\192')
  264. eq(
  265. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 is not a dict',
  266. exc_exec(sdrcmd())
  267. )
  268. end)
  269. -- rc entry is here because it causes an allocation
  270. it('fails on register item with BIN key', function()
  271. wshada('\005\000\014\131\162rc\145\196\001a\162rX\192\160\000')
  272. eq(
  273. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has empty key',
  274. exc_exec(sdrcmd())
  275. )
  276. end)
  277. it('fails on register item with NIL rt key value', function()
  278. wshada('\005\000\009\130\162rX\192\162rt\192')
  279. eq(
  280. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rt key value which is not an integer',
  281. exc_exec(sdrcmd())
  282. )
  283. end)
  284. it('fails on register item with NIL rw key value', function()
  285. wshada('\005\000\009\130\162rX\192\162rw\192')
  286. eq(
  287. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rw key value which is not an integer',
  288. exc_exec(sdrcmd())
  289. )
  290. end)
  291. it('fails on register item with NIL rc key value', function()
  292. wshada('\005\000\009\130\162rX\192\162rc\192')
  293. eq(
  294. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with non-array value',
  295. exc_exec(sdrcmd())
  296. )
  297. end)
  298. it('fails on register item with empty rc key value', function()
  299. wshada('\005\000\009\130\162rX\192\162rc\144')
  300. eq(
  301. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with missing or empty array',
  302. exc_exec(sdrcmd())
  303. )
  304. end)
  305. it('fails on register item with NIL in rc array', function()
  306. wshada('\005\000\013\130\162rX\192\162rc\146\196\001a\192')
  307. eq(
  308. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc array with non-binary value',
  309. exc_exec(sdrcmd())
  310. )
  311. end)
  312. it('fails on register item without rc array', function()
  313. wshada('\005\000\009\129\162rX\146\196\001a\192')
  314. eq(
  315. 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with missing or empty array',
  316. exc_exec(sdrcmd())
  317. )
  318. end)
  319. it('fails on history item with NIL value', function()
  320. wshada('\004\000\001\192')
  321. eq(
  322. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
  323. exc_exec(sdrcmd())
  324. )
  325. end)
  326. it('fails on history item with empty value', function()
  327. wshada('\004\000\001\144')
  328. eq(
  329. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
  330. exc_exec(sdrcmd())
  331. )
  332. end)
  333. it('fails on history item with single element value', function()
  334. wshada('\004\000\002\145\000')
  335. eq(
  336. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
  337. exc_exec(sdrcmd())
  338. )
  339. end)
  340. it('fails on history item with NIL first item', function()
  341. wshada('\004\000\003\146\192\000')
  342. eq(
  343. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 has wrong history type type',
  344. exc_exec(sdrcmd())
  345. )
  346. end)
  347. it('fails on history item with FIXUINT second item', function()
  348. wshada('\004\000\003\146\000\000')
  349. eq(
  350. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 has wrong history string type',
  351. exc_exec(sdrcmd())
  352. )
  353. end)
  354. it('fails on history item with second item with zero byte', function()
  355. wshada('\004\000\007\146\000\196\003ab\000')
  356. eq(
  357. 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 contains string with zero byte inside',
  358. exc_exec(sdrcmd())
  359. )
  360. end)
  361. it('fails on search history item without third item', function()
  362. wshada('\004\000\007\146\001\196\003abc')
  363. eq(
  364. 'Vim(rshada):E575: Error while reading ShaDa file: search history entry at position 0 does not have separator character',
  365. exc_exec(sdrcmd())
  366. )
  367. end)
  368. it('fails on search history item with NIL third item', function()
  369. wshada('\004\000\007\147\001\196\002ab\192')
  370. eq(
  371. 'Vim(rshada):E575: Error while reading ShaDa file: search history entry at position 0 has wrong history separator type',
  372. exc_exec(sdrcmd())
  373. )
  374. end)
  375. it('fails on variable item with NIL value', function()
  376. wshada('\006\000\001\192')
  377. eq(
  378. 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
  379. exc_exec(sdrcmd())
  380. )
  381. end)
  382. it('fails on variable item with empty value', function()
  383. wshada('\006\000\001\144')
  384. eq(
  385. 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
  386. exc_exec(sdrcmd())
  387. )
  388. end)
  389. it('fails on variable item with single element value', function()
  390. wshada('\006\000\002\145\000')
  391. eq(
  392. 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
  393. exc_exec(sdrcmd())
  394. )
  395. end)
  396. it('fails on variable item with NIL first item', function()
  397. wshada('\006\000\003\146\192\000')
  398. eq(
  399. 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 has wrong variable name type',
  400. exc_exec(sdrcmd())
  401. )
  402. end)
  403. it('fails on variable item with BIN value and type value != VAR_TYPE_BLOB', function()
  404. wshada('\006\000\007\147\196\001\065\196\000\000')
  405. eq(
  406. 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 has wrong variable type',
  407. exc_exec(sdrcmd())
  408. )
  409. end)
  410. it('fails on replacement item with NIL value', function()
  411. wshada('\003\000\001\192')
  412. eq(
  413. 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 is not an array with enough elements',
  414. exc_exec(sdrcmd())
  415. )
  416. end)
  417. it('fails on replacement item with empty value', function()
  418. wshada('\003\000\001\144')
  419. eq(
  420. 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 is not an array with enough elements',
  421. exc_exec(sdrcmd())
  422. )
  423. end)
  424. it('fails on replacement item with NIL first item', function()
  425. wshada('\003\000\002\145\192')
  426. eq(
  427. 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 has wrong sub string type',
  428. exc_exec(sdrcmd())
  429. )
  430. end)
  431. it('fails on buffer list item with NIL value', function()
  432. nvim_command('set shada+=%')
  433. wshada('\009\000\001\192')
  434. eq(
  435. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list entry at position 0 is not an array',
  436. exc_exec(sdrcmd())
  437. )
  438. end)
  439. it('fails on buffer list item with NIL item in the array', function()
  440. nvim_command('set shada+=%')
  441. wshada('\009\000\008\146\129\161f\196\001/\192')
  442. eq(
  443. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that is not a dict',
  444. exc_exec(sdrcmd())
  445. )
  446. end)
  447. it('fails on buffer list item with empty item', function()
  448. nvim_command('set shada+=%')
  449. wshada('\009\000\008\146\129\161f\196\001/\128')
  450. eq(
  451. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that does not have a file name',
  452. exc_exec(sdrcmd())
  453. )
  454. end)
  455. it('fails on buffer list item with NIL l key', function()
  456. nvim_command('set shada+=%')
  457. wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161l\192')
  458. eq(
  459. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that has l key value which is not an integer',
  460. exc_exec(sdrcmd())
  461. )
  462. end)
  463. it('fails on buffer list item with zero l key', function()
  464. nvim_command('set shada+=%')
  465. wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161l\000')
  466. eq(
  467. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry with invalid line number',
  468. exc_exec(sdrcmd())
  469. )
  470. end)
  471. it('fails on buffer list item with negative l key', function()
  472. nvim_command('set shada+=%')
  473. wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161l\255')
  474. eq(
  475. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry with invalid line number',
  476. exc_exec(sdrcmd())
  477. )
  478. end)
  479. it('fails on buffer list item with negative c key', function()
  480. nvim_command('set shada+=%')
  481. wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161c\255')
  482. eq(
  483. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry with invalid column number',
  484. exc_exec(sdrcmd())
  485. )
  486. end)
  487. it('fails on buffer list item with NIL c key', function()
  488. nvim_command('set shada+=%')
  489. wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161c\192')
  490. eq(
  491. 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that has c key value which is not an integer',
  492. exc_exec(sdrcmd())
  493. )
  494. end)
  495. it('fails on invalid ShaDa file (viminfo file)', function()
  496. wshada([[# This viminfo file was generated by Vim 7.4.
  497. # You may edit it if you're careful!
  498. # Value of 'encoding' when this file was written
  499. *encoding=utf-8
  500. # hlsearch on (H) or off (h):
  501. ~h
  502. # Last Search Pattern:
  503. ~MSle0~/buffer=abuf
  504. # Last Substitute Search Pattern:
  505. ~MSle0&^$
  506. # Last Substitute String:
  507. $
  508. # Command Line History (newest to oldest):
  509. :cq
  510. # Search String History (newest to oldest):
  511. ? \<TMUX\>
  512. # Expression History (newest to oldest):
  513. =system('echo "\xAB"')
  514. # Input Line History (newest to oldest):
  515. @i
  516. # Input Line History (newest to oldest):
  517. # Registers:
  518. "0 LINE 0
  519. case FLAG_B: puts("B"); break;
  520. "1 LINE 0
  521. pick 874a489 shada,functests: Test compatibility support
  522. ""- CHAR 0
  523. .
  524. # global variables:
  525. !STUF_HISTORY_TRANSLIT LIS []
  526. !TR3_INPUT_HISTORY LIS []
  527. # File marks:
  528. 'A 8320 12 ~/a.a/Proj/c/neovim-2076/src/nvim/ex_docmd.c
  529. '0 66 5 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  530. '1 7 0 ~/.vam/powerline/.git/MERGE_MSG
  531. '2 64 4 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  532. '3 9 0 ~/a.a/Proj/c/neovim/.git/COMMIT_EDITMSG
  533. '4 62 0 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  534. '5 57 4 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  535. '6 1 0 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  536. '7 399 7 /usr/share/vim/vim74/doc/motion.txt
  537. '8 1 0 ~/a.a/Proj/c/zpython/build/CMakeFiles/3.2.2/CMakeCCompiler.cmake
  538. '9 1 0 ~/a.a/Proj/c/vim/README.txt
  539. # Jumplist (newest first):
  540. -' 66 5 ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  541. # History of marks within files (newest to oldest):
  542. > ~/a.a/Proj/c/neovim/.git/rebase-merge/git-rebase-todo
  543. " 66 5
  544. ^ 66 6
  545. . 66 5
  546. + 65 0
  547. + 65 0
  548. ]])
  549. eq(
  550. 'Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3',
  551. exc_exec(sdrcmd())
  552. )
  553. eq(
  554. 'Vim(wshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3',
  555. exc_exec('wshada ' .. shada_fname)
  556. )
  557. eq(0, exc_exec('wshada! ' .. shada_fname))
  558. end)
  559. it('fails on invalid ShaDa file (wrapper script)', function()
  560. wshada('#!/bin/sh\n\npowerline "$@" 2>&1 | tee -a powerline\n')
  561. eq(
  562. 'Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3',
  563. exc_exec(sdrcmd())
  564. )
  565. eq(
  566. 'Vim(wshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3',
  567. exc_exec('wshada ' .. shada_fname)
  568. )
  569. eq(0, exc_exec('wshada! ' .. shada_fname))
  570. end)
  571. it('fails on invalid ShaDa file (failing skip in second item)', function()
  572. wshada('\001\000\001\128#!/')
  573. eq(
  574. 'Vim(rshada):E576: Error while reading ShaDa file: last entry specified that it occupies 47 bytes, but file ended earlier',
  575. exc_exec(sdrcmd())
  576. )
  577. eq(
  578. 'Vim(wshada):E576: Error while reading ShaDa file: last entry specified that it occupies 47 bytes, but file ended earlier',
  579. exc_exec('wshada ' .. shada_fname)
  580. )
  581. eq(0, exc_exec('wshada! ' .. shada_fname))
  582. end)
  583. it('errors with too large items', function()
  584. wshada({
  585. 1,
  586. 206,
  587. 70,
  588. 90,
  589. 31,
  590. 179,
  591. 86,
  592. 133,
  593. 169,
  594. 103,
  595. 101,
  596. 110,
  597. 101,
  598. 114,
  599. 97,
  600. 116,
  601. 111,
  602. 114,
  603. 196,
  604. 4,
  605. 145,
  606. 145,
  607. 145,
  608. 145,
  609. 145,
  610. 145,
  611. 96,
  612. 96,
  613. 96,
  614. 96,
  615. 96,
  616. 96,
  617. 96,
  618. 96,
  619. 96,
  620. 96,
  621. 96,
  622. 96,
  623. 96,
  624. 96,
  625. 96,
  626. 96,
  627. 96,
  628. 96,
  629. 96,
  630. 96,
  631. 96,
  632. 145,
  633. 145,
  634. 145,
  635. 145,
  636. 111,
  637. 110,
  638. 196,
  639. 25,
  640. 78,
  641. 86,
  642. 73,
  643. 77,
  644. 32,
  645. 118,
  646. 1,
  647. 46,
  648. 50,
  649. 46,
  650. 48,
  651. 45,
  652. 51,
  653. 48,
  654. 51,
  655. 45,
  656. 103,
  657. 98,
  658. 54,
  659. 55,
  660. 52,
  661. 102,
  662. 100,
  663. 50,
  664. 99,
  665. 169,
  666. 109,
  667. 97,
  668. 120,
  669. 95,
  670. 107,
  671. 98,
  672. 121,
  673. 116,
  674. 101,
  675. 10,
  676. 207,
  677. 207,
  678. 207,
  679. 207,
  680. 207,
  681. 207,
  682. 207,
  683. 207,
  684. 207,
  685. 207,
  686. 207,
  687. 207,
  688. 207,
  689. 207,
  690. 207,
  691. 207,
  692. 207,
  693. 207,
  694. 207,
  695. 207,
  696. 207,
  697. 207,
  698. 16,
  699. 8,
  700. 206,
  701. 89,
  702. 90,
  703. 30,
  704. 253,
  705. 35,
  706. 129,
  707. 161,
  708. 102,
  709. 196,
  710. 30,
  711. 47,
  712. 100,
  713. 101,
  714. 118,
  715. 47,
  716. 115,
  717. 104,
  718. 109,
  719. 47,
  720. 102,
  721. 117,
  722. 122,
  723. 122,
  724. 105,
  725. 110,
  726. 103,
  727. 45,
  728. 110,
  729. 118,
  730. 105,
  731. 109,
  732. 45,
  733. 115,
  734. 104,
  735. 97,
  736. 100,
  737. 97,
  738. 47,
  739. 108,
  740. 115,
  741. 2,
  742. 206,
  743. 89,
  744. 90,
  745. 30,
  746. 251,
  747. 13,
  748. 130,
  749. 162,
  750. 115,
  751. 112,
  752. 196,
  753. 3,
  754. 102,
  755. 111,
  756. 111,
  757. 162,
  758. 115,
  759. 99,
  760. 195,
  761. 3,
  762. 146,
  763. 10,
  764. 0,
  765. })
  766. eq(
  767. 'Vim(rshada):E576: Error while reading ShaDa file: there is an item at position 93 that is stated to be too long',
  768. exc_exec(sdrcmd())
  769. )
  770. end)
  771. end)