]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0673: tests: Test_recover_corrupted_swap_file() cannot handle symlinks v9.2.0673
authorVladimír Marek <vlmarek13@gmail.com>
Thu, 18 Jun 2026 19:02:56 +0000 (19:02 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 18 Jun 2026 19:02:56 +0000 (19:02 +0000)
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: #20561

Signed-off-by: Vladimír Marek <vlmarek13@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_recover.vim
src/version.c

index 69caa89135f30afd6353055f332ae0c9f5655c92..bb61e1995d3a9f7c6600acb7ef3a2ddc026eb2bb 100644 (file)
@@ -503,7 +503,9 @@ func Test_recover_corrupted_swap_file1()
   new
   let sample = 'samples/recover-crash1.swp'
   let target = 'Xpoc1.swp'
-  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:/
@@ -517,7 +519,9 @@ func Test_recover_corrupted_swap_file1()
   new
   let sample = 'samples/recover-crash2.swp'
   let target = 'Xpoc2.swp'
-  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:/
index af26854acb29951e3cbfe048230206ffcc630e9e..14ba1f8ed1b17b1d86751a728bc89bb4b571938a 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    673,
 /**/
     672,
 /**/