From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- test/old/testdir/test_recover.vim | 467 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 467 insertions(+) create mode 100644 test/old/testdir/test_recover.vim (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim new file mode 100644 index 0000000000..92e22687af --- /dev/null +++ b/test/old/testdir/test_recover.vim @@ -0,0 +1,467 @@ +" Test :recover + +source check.vim + +func Test_recover_root_dir() + " This used to access invalid memory. + split Xtest + set dir=/ + call assert_fails('recover', 'E305:') + close! + + if has('win32') + " can write in / directory on MS-Windows + let &directory = 'F:\\' + elseif filewritable('/') == 2 + set dir=/notexist/ + endif + call assert_fails('split Xtest', 'E303:') + + " No error with empty 'directory' setting. + set directory= + split XtestOK + close! + + set dir& +endfunc + +" Make a copy of the current swap file to "Xswap". +" Return the name of the swap file. +func CopySwapfile() + preserve + " get the name of the swap file + let swname = split(execute("swapname"))[0] + let swname = substitute(swname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '') + " make a copy of the swap file in Xswap + set binary + exe 'sp ' . swname + w! Xswap + set nobinary + return swname +endfunc + +" Inserts 10000 lines with text to fill the swap file with two levels of pointer +" blocks. Then recovers from the swap file and checks all text is restored. +" +" We need about 10000 lines of 100 characters to get two levels of pointer +" blocks. +func Test_swap_file() + set directory=. + set fileformat=unix undolevels=-1 + edit! Xtest + let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789" + let i = 1 + let linecount = 10000 + while i <= linecount + call append(i - 1, i . text) + let i += 1 + endwhile + $delete + + let swname = CopySwapfile() + + new + only! + bwipe! Xtest + call rename('Xswap', swname) + recover Xtest + call delete(swname) + let linedollar = line('$') + call assert_equal(linecount, linedollar) + if linedollar < linecount + let linecount = linedollar + endif + let i = 1 + while i <= linecount + call assert_equal(i . text, getline(i)) + let i += 1 + endwhile + + set undolevels& + enew! | only +endfunc + +func Test_nocatch_process_still_running() + let g:skipped_reason = 'test_override() is N/A' + return + " sysinfo.uptime probably only works on Linux + if !has('linux') + let g:skipped_reason = 'only works on Linux' + return + endif + " the GUI dialog can't be handled + if has('gui_running') + let g:skipped_reason = 'only works in the terminal' + return + endif + + " don't intercept existing swap file here + au! SwapExists + + " Edit a file and grab its swapfile. + edit Xswaptest + call setline(1, ['a', 'b', 'c']) + let swname = CopySwapfile() + + " Forget we edited this file + new + only! + bwipe! Xswaptest + + call rename('Xswap', swname) + call feedkeys('e', 'tL') + redir => editOutput + edit Xswaptest + redir END + call assert_match('E325: ATTENTION', editOutput) + call assert_match('file name: .*Xswaptest', editOutput) + call assert_match('process ID: \d* (STILL RUNNING)', editOutput) + + " Forget we edited this file + new + only! + bwipe! Xswaptest + + " pretend we rebooted + call test_override("uptime", 0) + sleep 1 + + call feedkeys('e', 'tL') + redir => editOutput + edit Xswaptest + redir END + call assert_match('E325: ATTENTION', editOutput) + call assert_notmatch('(STILL RUNNING)', editOutput) + + call test_override("ALL", 0) + call delete(swname) +endfunc + +" Test for :recover with multiple swap files +func Test_recover_multiple_swap_files() + CheckUnix + new Xfile1 + call setline(1, ['a', 'b', 'c']) + preserve + let b = readblob(swapname('')) + call writefile(b, '.Xfile1.swm') + call writefile(b, '.Xfile1.swn') + call writefile(b, '.Xfile1.swo') + %bw! + call feedkeys(":recover Xfile1\3\q", 'xt') + call assert_equal(['a', 'b', 'c'], getline(1, '$')) + " try using out-of-range number to select a swap file + bw! + call feedkeys(":recover Xfile1\4\q", 'xt') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + call feedkeys(":recover Xfile1\0\q", 'xt') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + call delete('.Xfile1.swm') + call delete('.Xfile1.swn') + call delete('.Xfile1.swo') +endfunc + +" Test for :recover using an empty swap file +func Test_recover_empty_swap_file() + CheckUnix + call writefile([], '.Xfile1.swp') + let msg = execute('recover Xfile1') + call assert_match('Unable to read block 0 from .Xfile1.swp', msg) + call assert_equal('Xfile1', @%) + bw! + + " make sure there are no old swap files laying around + for f in glob('.sw?', 0, 1) + call delete(f) + endfor + + " :recover from an empty buffer + call assert_fails('recover', 'E305:') + call delete('.Xfile1.swp') +endfunc + +" Test for :recover using a corrupted swap file +" Refer to the comments in the memline.c file for the swap file headers +" definition. +func Test_recover_corrupted_swap_file() + CheckUnix + + " recover using a partial swap file + call writefile(0z1234, '.Xfile1.swp') + call assert_fails('recover Xfile1', 'E295:') + bw! + + " recover using invalid content in the swap file + call writefile([repeat('1', 2*1024)], '.Xfile1.swp') + call assert_fails('recover Xfile1', 'E307:') + call delete('.Xfile1.swp') + + " :recover using a swap file with a corrupted header + edit Xfile1 + preserve + let sn = swapname('') + let b = readblob(sn) + let save_b = copy(b) + bw! + + " Not all fields are written in a system-independent manner. Detect whether + " the test is running on a little or big-endian system, so the correct + " corruption values can be set. + " The B0_MAGIC_LONG field may be 32-bit or 64-bit, depending on the system, + " even though the value stored is only 32-bits. Therefore, need to check + " both the high and low 32-bits to compute these values. + let little_endian = (b[1008:1011] == 0z33323130) || (b[1012:1015] == 0z33323130) + let system_64bit = little_endian ? (b[1012:1015] == 0z00000000) : (b[1008:1011] == 0z00000000) + + " clear the B0_MAGIC_LONG field + if system_64bit + let b[1008:1015] = 0z00000000.00000000 + else + let b[1008:1011] = 0z00000000 + endif + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('the file has been damaged', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " reduce the page size + let b = copy(save_b) + let b[12:15] = 0z00010000 + call writefile(b, sn) + let msg = execute('recover Xfile1') + call assert_match('page size is smaller than minimum value', msg) + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " clear the pointer ID + let b = copy(save_b) + let b[4096:4097] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E310:') + call assert_equal('Xfile1', @%) + call assert_equal([''], getline(1, '$')) + bw! + + " set the number of pointers in a pointer block to zero + let b = copy(save_b) + let b[4098:4099] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???EMPTY BLOCK'], getline(1, '$')) + bw! + + " set the block number in a pointer entry to a negative number + let b = copy(save_b) + if system_64bit + let b[4104:4111] = little_endian ? 0z00000000.00000080 : 0z80000000.00000000 + else + let b[4104:4107] = little_endian ? 0z00000080 : 0z80000000 + endif + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???LINES MISSING'], getline(1, '$')) + bw! + + " clear the data block ID + let b = copy(save_b) + let b[8192:8193] = 0z0000 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???BLOCK MISSING'], getline(1, '$')) + bw! + + " set the number of lines in the data block to zero + let b = copy(save_b) + if system_64bit + let b[8208:8215] = 0z00000000.00000000 + else + let b[8208:8211] = 0z00000000 + endif + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may have been inserted/deleted', + \ '???END'], getline(1, '$')) + bw! + + " use an invalid text start for the lines in a data block + let b = copy(save_b) + if system_64bit + let b[8216:8219] = 0z00000000 + else + let b[8212:8215] = 0z00000000 + endif + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???'], getline(1, '$')) + bw! + + " use an incorrect text end (db_txt_end) for the data block + let b = copy(save_b) + let b[8204:8207] = little_endian ? 0z80000000 : 0z00000080 + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may be messed up', '', + \ '???END'], getline(1, '$')) + bw! + + " remove the data block + let b = copy(save_b) + call writefile(b[:8191], sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['???MANY LINES MISSING'], getline(1, '$')) + + bw! + call delete(sn) +endfunc + +" Test for :recover using an encrypted swap file +func Test_recover_encrypted_swap_file() + CheckFeature cryptv + CheckUnix + + " Recover an encrypted file from the swap file without the original file + new Xfile1 + call feedkeys(":X\vim\vim\", 'xt') + call setline(1, ['aaa', 'bbb', 'ccc']) + preserve + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call feedkeys(":recover Xfile1\vim\\", 'xt') + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + bw! + call delete('.Xfile1.swm') + + " Recover an encrypted file from the swap file with the original file + new Xfile1 + call feedkeys(":X\vim\vim\", 'xt') + call setline(1, ['aaa', 'bbb', 'ccc']) + update + call setline(1, ['111', '222', '333']) + preserve + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call feedkeys(":recover Xfile1\vim\\", 'xt') + call assert_equal(['111', '222', '333'], getline(1, '$')) + call assert_true(&modified) + bw! + call delete('.Xfile1.swm') + call delete('Xfile1') +endfunc + +" Test for :recover using a unreadable swap file +func Test_recover_unreadble_swap_file() + CheckUnix + CheckNotRoot + new Xfile1 + let b = readblob('.Xfile1.swp') + call writefile(b, '.Xfile1.swm') + bw! + call setfperm('.Xfile1.swm', '-w-------') + call assert_fails('recover Xfile1', 'E306:') + call delete('.Xfile1.swm') +endfunc + +" Test for using :recover when the original file and the swap file have the +" same contents. +func Test_recover_unmodified_file() + CheckUnix + call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') + edit Xfile1 + preserve + let b = readblob('.Xfile1.swp') + %bw! + call writefile(b, '.Xfile1.swz') + let msg = execute('recover Xfile1') + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + call assert_false(&modified) + call assert_match('Buffer contents equals file contents', msg) + bw! + call delete('Xfile1') + call delete('.Xfile1.swz') +endfunc + +" Test for recovering a file when editing a symbolically linked file +func Test_recover_symbolic_link() + CheckUnix + call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') + silent !ln -s Xfile1 Xfile2 + edit Xfile2 + call assert_equal('.Xfile1.swp', fnamemodify(swapname(''), ':t')) + preserve + let b = readblob('.Xfile1.swp') + %bw! + call writefile([], 'Xfile1') + call writefile(b, '.Xfile1.swp') + silent! recover Xfile2 + call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) + call assert_true(&modified) + update + %bw! + call assert_equal(['aaa', 'bbb', 'ccc'], readfile('Xfile1')) + call delete('Xfile1') + call delete('Xfile2') + call delete('.Xfile1.swp') +endfunc + +" Test for recovering a file when an autocmd moves the cursor to an invalid +" line. This used to result in an internal error (E315) which is fixed +" by 8.2.2966. +func Test_recover_invalid_cursor_pos() + call writefile([], 'Xfile1') + edit Xfile1 + preserve + let b = readblob('.Xfile1.swp') + bw! + augroup Test + au! + au BufReadPost Xfile1 normal! 3G + augroup END + call writefile(range(1, 3), 'Xfile1') + call writefile(b, '.Xfile1.swp') + try + recover Xfile1 + catch /E308:/ + " this test is for the :E315 internal error. + " ignore the 'E308: Original file may have been changed' error + endtry + redraw! + augroup Test + au! + augroup END + augroup! Test + call delete('Xfile1') + call delete('.Xfile1.swp') +endfunc + +" Test for recovering a buffer without a name +func Test_noname_buffer() + new + call setline(1, ['one', 'two']) + preserve + let sn = swapname('') + let b = readblob(sn) + bw! + call writefile(b, sn) + exe "recover " .. sn + call assert_equal(['one', 'two'], getline(1, '$')) + call delete(sn) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From 77ff25b1d9ab5869d852779cae8fc6a1245f3ea7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Apr 2023 08:24:10 +0800 Subject: vim-patch:9.0.1477: crash when recovering from corrupted swap file (#23273) Problem: Crash when recovering from corrupted swap file. Solution: Check for a valid page count. (closes vim/vim#12275) https://github.com/vim/vim/commit/b67ba03d3ef2e6c5f207d508e85fc6906f938028 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_recover.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index 92e22687af..81e2dde1e2 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -259,6 +259,14 @@ func Test_recover_corrupted_swap_file() call assert_equal(['???EMPTY BLOCK'], getline(1, '$')) bw! + " set the number of pointers in a pointer block to a large value + let b = copy(save_b) + let b[4098:4099] = 0zFFFF + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E1364:') + call assert_equal('Xfile1', @%) + bw! + " set the block number in a pointer entry to a negative number let b = copy(save_b) if system_64bit -- cgit From 95839a23581ad678e6dc34bc2935d78f516639e7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Apr 2023 06:27:51 +0800 Subject: vim-patch:9.0.1494: crash when recovering from corrupted swap file (#23358) Problem: Crash when recovering from corrupted swap file. Solution: Bail out when the line index looks wrong. (closes vim/vim#12276) https://github.com/vim/vim/commit/bf1b7132021bac0fccefebb4a1c24a5f372bae4f Co-authored-by: Bram Moolenaar --- test/old/testdir/test_recover.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index 81e2dde1e2..e5ea144d31 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -303,6 +303,21 @@ func Test_recover_corrupted_swap_file() \ '???END'], getline(1, '$')) bw! + " set the number of lines in the data block to a large value + let b = copy(save_b) + if system_64bit + let b[8208:8215] = 0z00FFFFFF.FFFFFF00 + else + let b[8208:8211] = 0z00FFFF00 + endif + call writefile(b, sn) + call assert_fails('recover Xfile1', 'E312:') + call assert_equal('Xfile1', @%) + call assert_equal(['??? from here until ???END lines may have been inserted/deleted', + \ '', '???', '??? lines may be missing', + \ '???END'], getline(1, '$')) + bw! + " use an invalid text start for the lines in a data block let b = copy(save_b) if system_64bit -- cgit From 3e5a7f258a94bb753df57d4ea6c3b56a70906a22 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 6 Sep 2023 06:19:49 +0800 Subject: vim-patch:partial:9.0.0669: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible. https://github.com/vim/vim/commit/db77cb3c08784e6038dd029271b2080c1b2d9acb Include test_recover.vim changes only. Cherry-pick test_recover.vim change from patch 8.2.3637. Co-authored-by: Bram Moolenaar --- test/old/testdir/test_recover.vim | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index e5ea144d31..ef8873520b 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -144,9 +144,9 @@ func Test_recover_multiple_swap_files() call setline(1, ['a', 'b', 'c']) preserve let b = readblob(swapname('')) - call writefile(b, '.Xfile1.swm') - call writefile(b, '.Xfile1.swn') - call writefile(b, '.Xfile1.swo') + call writefile(b, '.Xfile1.swm', 'D') + call writefile(b, '.Xfile1.swn', 'D') + call writefile(b, '.Xfile1.swo', 'D') %bw! call feedkeys(":recover Xfile1\3\q", 'xt') call assert_equal(['a', 'b', 'c'], getline(1, '$')) @@ -160,16 +160,12 @@ func Test_recover_multiple_swap_files() call assert_equal('Xfile1', @%) call assert_equal([''], getline(1, '$')) bw! - - call delete('.Xfile1.swm') - call delete('.Xfile1.swn') - call delete('.Xfile1.swo') endfunc " Test for :recover using an empty swap file func Test_recover_empty_swap_file() CheckUnix - call writefile([], '.Xfile1.swp') + call writefile([], '.Xfile1.swp', 'D') let msg = execute('recover Xfile1') call assert_match('Unable to read block 0 from .Xfile1.swp', msg) call assert_equal('Xfile1', @%) @@ -182,7 +178,6 @@ func Test_recover_empty_swap_file() " :recover from an empty buffer call assert_fails('recover', 'E305:') - call delete('.Xfile1.swp') endfunc " Test for :recover using a corrupted swap file @@ -389,16 +384,15 @@ func Test_recover_encrypted_swap_file() endfunc " Test for :recover using a unreadable swap file -func Test_recover_unreadble_swap_file() +func Test_recover_unreadable_swap_file() CheckUnix CheckNotRoot new Xfile1 let b = readblob('.Xfile1.swp') - call writefile(b, '.Xfile1.swm') + call writefile(b, '.Xfile1.swm', 'D') bw! call setfperm('.Xfile1.swm', '-w-------') call assert_fails('recover Xfile1', 'E306:') - call delete('.Xfile1.swm') endfunc " Test for using :recover when the original file and the swap file have the @@ -410,20 +404,19 @@ func Test_recover_unmodified_file() preserve let b = readblob('.Xfile1.swp') %bw! - call writefile(b, '.Xfile1.swz') + call writefile(b, '.Xfile1.swz', 'D') let msg = execute('recover Xfile1') call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) call assert_false(&modified) call assert_match('Buffer contents equals file contents', msg) bw! call delete('Xfile1') - call delete('.Xfile1.swz') endfunc " Test for recovering a file when editing a symbolically linked file func Test_recover_symbolic_link() CheckUnix - call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') + call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1', 'D') silent !ln -s Xfile1 Xfile2 edit Xfile2 call assert_equal('.Xfile1.swp', fnamemodify(swapname(''), ':t')) @@ -438,7 +431,6 @@ func Test_recover_symbolic_link() update %bw! call assert_equal(['aaa', 'bbb', 'ccc'], readfile('Xfile1')) - call delete('Xfile1') call delete('Xfile2') call delete('.Xfile1.swp') endfunc @@ -447,7 +439,7 @@ endfunc " line. This used to result in an internal error (E315) which is fixed " by 8.2.2966. func Test_recover_invalid_cursor_pos() - call writefile([], 'Xfile1') + call writefile([], 'Xfile1', 'D') edit Xfile1 preserve let b = readblob('.Xfile1.swp') @@ -457,7 +449,7 @@ func Test_recover_invalid_cursor_pos() au BufReadPost Xfile1 normal! 3G augroup END call writefile(range(1, 3), 'Xfile1') - call writefile(b, '.Xfile1.swp') + call writefile(b, '.Xfile1.swp', 'D') try recover Xfile1 catch /E308:/ @@ -469,8 +461,6 @@ func Test_recover_invalid_cursor_pos() au! augroup END augroup! Test - call delete('Xfile1') - call delete('.Xfile1.swp') endfunc " Test for recovering a buffer without a name @@ -481,10 +471,9 @@ func Test_noname_buffer() let sn = swapname('') let b = readblob(sn) bw! - call writefile(b, sn) + call writefile(b, sn, 'D') exe "recover " .. sn call assert_equal(['one', 'two'], getline(1, '$')) - call delete(sn) endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From 0909843647e508681cbfd53ee7ddc9b2422f136d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 6 Sep 2023 06:21:38 +0800 Subject: vim-patch:9.0.1874: CI may fail in test_recover_empty_swap Problem: CI may fail in test_recover_empty_swap Solution: Set directory option Fix failing Test_recover_empty_swap test :recover by default not only looks in the current directory, but also in ~/tmp for files to recover. If it finds some files to recover, it will interactively prompt for a file to recover. However, prompting doesn't work when running the test suite (and even if it would, there is no one that can answer the prompt). So it doesn't really make sense during testing, to inspect different directories for swap files and prompt and wait (which will lead to a timeout and therefore a failing test). So set the 'directory' option temporarily to the current directory only and reset it back once the test finishes. closes: vim/vim#13038 https://github.com/vim/vim/commit/1c7397f3f1e168541f88bb1bbd93a9f0b1235852 Co-authored-by: Christian Brabandt --- test/old/testdir/test_recover.vim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index ef8873520b..36a9cff073 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -166,6 +166,7 @@ endfunc func Test_recover_empty_swap_file() CheckUnix call writefile([], '.Xfile1.swp', 'D') + set dir=. let msg = execute('recover Xfile1') call assert_match('Unable to read block 0 from .Xfile1.swp', msg) call assert_equal('Xfile1', @%) @@ -178,6 +179,7 @@ func Test_recover_empty_swap_file() " :recover from an empty buffer call assert_fails('recover', 'E305:') + set dir&vim endfunc " Test for :recover using a corrupted swap file -- cgit From a1ded1b113d22f4ec8c14fab4aff5f9d0c43f8b4 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 24 Nov 2023 15:22:00 -0500 Subject: fix(oldtest): always use a 64-bit int for swapfile block number 09d4133 changed blocknr_T from long to int64_t, so pe_bnum is now always 64-bit. This was an incompatible change in the swapfile format for 32-bit systems, but there have been no complaints in the past 9 years so just adjust the test. --- test/old/testdir/test_recover.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/old/testdir/test_recover.vim') diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index 36a9cff073..fa8cc1abaf 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -266,7 +266,7 @@ func Test_recover_corrupted_swap_file() " set the block number in a pointer entry to a negative number let b = copy(save_b) - if system_64bit + if v:true " Nvim changed this field from a long to an int64_t let b[4104:4111] = little_endian ? 0z00000000.00000080 : 0z80000000.00000000 else let b[4104:4107] = little_endian ? 0z00000080 : 0z80000000 -- cgit