From 147872452ec4f7190e8f3a3e6255b8f1ca9bbf60 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Jun 2026 09:39:45 +0800 Subject: [PATCH] vim-patch:9.2.0673: tests: Test_recover_corrupted_swap_file() cannot handle symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: tests: Test_recover_corrupted_swap_file() cannot handle symlinks Solution: Use writefile(readblob()) instead (Vladimír Marek) Test_recover_corrupted_swap_file1() copies prebuilt corrupt swap samples before recovering them. In an out-of-source-tree build those sample files may be symlinks into the source tree. filecopy() preserves symlinks, so the copied target may remain a symlink. Recovery opens swap files with O_NOFOLLOW, so that copied symlink cannot be opened. Read the sample as a blob and write it back so the recovery target is a real swap file. closes: vim/vim#20561 https://github.com/vim/vim/commit/88cbd003125840ed20f455653e28b91e3237f380 Co-authored-by: Vladimír Marek --- test/old/testdir/test_recover.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/old/testdir/test_recover.vim b/test/old/testdir/test_recover.vim index c33427572e..2a5c453406 100644 --- a/test/old/testdir/test_recover.vim +++ b/test/old/testdir/test_recover.vim @@ -508,7 +508,9 @@ func Test_recover_corrupted_swap_file1() new let sample = 'samples/recover-crash1.swp' let target = '.Xpoc1.swp' " Xpoc1.swp (non-hidden) doesn't work in Nvim - call filecopy(sample, target) + " In an out-of-source-tree build the sample may be a symlink, this copies the + " data into a real file. + call writefile(readblob(sample), target, 'D') try sil recover! Xpoc1 catch /^Vim\%((\S\+)\)\=:E1364:/ @@ -522,7 +524,9 @@ func Test_recover_corrupted_swap_file1() new let sample = 'samples/recover-crash2.swp' let target = '.Xpoc2.swp' " Xpoc1.swp (non-hidden) doesn't work in Nvim - call filecopy(sample, target) + " In an out-of-source-tree build the sample may be a symlink, this copies the + " data into a real file. + call writefile(readblob(sample), target, 'D') try sil recover! Xpoc2 catch /^Vim\%((\S\+)\)\=:E1364:/