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