robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

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