summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-25 12:43:28 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-25 12:43:28 +0100
commit5ee0981fb5259f94900ab25207caddf1fa61010d (patch)
treede45d49c38e4407511d6c1737390d32228e76d66
parentff94bd9e4779b918f3761035f43a97ba7175b3ce (diff)
patch 8.2.2044: MS-Windows: swap file test sometimes failsv8.2.2044
Problem: MS-Windows: swap file test sometimes fails. Solution: Use a more reliable way to change the process ID. When "timeout" fails use "ping" to wait up to ten minutes. (Ken Takata, closes #7365)
-rw-r--r--.github/workflows/ci-windows.yaml3
-rw-r--r--src/testdir/test_swap.vim39
-rw-r--r--src/version.c2
3 files changed, 40 insertions, 4 deletions
diff --git a/.github/workflows/ci-windows.yaml b/.github/workflows/ci-windows.yaml
index 7db551fdcb..4a470624b8 100644
--- a/.github/workflows/ci-windows.yaml
+++ b/.github/workflows/ci-windows.yaml
@@ -215,7 +215,8 @@ jobs:
:: Wait about 10 minutes.
for /L %%i in (1,1,60) do (
if exist done.txt goto exitloop
- timeout 10
+ timeout 10 > NUL 2>&1
+ if ERRORLEVEL 1 ping -n 11 localhost > NUL
)
set timeout=1
:exitloop
diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim
index 54ba7342c7..5f3f24da6a 100644
--- a/src/testdir/test_swap.vim
+++ b/src/testdir/test_swap.vim
@@ -403,6 +403,39 @@ func Test_swap_symlink()
call delete('Xswapdir', 'rf')
endfunc
+func s:get_unused_pid(base)
+ if has('job')
+ " Execute 'echo' as a temporary job, and return its pid as an unused pid.
+ if has('win32')
+ let cmd = 'cmd /c echo'
+ else
+ let cmd = 'echo'
+ endif
+ let j = job_start(cmd)
+ while job_status(j) ==# 'run'
+ sleep 10m
+ endwhile
+ if job_status(j) ==# 'dead'
+ return job_info(j).process
+ endif
+ endif
+ " Must add four for MS-Windows to see it as a different one.
+ return a:base + 4
+endfunc
+
+func s:blob_to_pid(b)
+ return a:b[3] * 16777216 + a:b[2] * 65536 + a:b[1] * 256 + a:b[0]
+endfunc
+
+func s:pid_to_blob(i)
+ let b = 0z
+ let b[0] = and(a:i, 0xff)
+ let b[1] = and(a:i / 256, 0xff)
+ let b[2] = and(a:i / 65536, 0xff)
+ let b[3] = and(a:i / 16777216, 0xff)
+ return b
+endfunc
+
func Test_swap_auto_delete()
" Create a valid swapfile by editing a file with a special extension.
split Xtest.scr
@@ -416,9 +449,9 @@ func Test_swap_auto_delete()
" Forget about the file, recreate the swap file, then edit it again. The
" swap file should be automatically deleted.
bwipe!
- " Change the process ID to avoid the "still running" warning. Must add four
- " for MS-Windows to see it as a different one.
- let swapfile_bytes[24] = swapfile_bytes[24] + 4
+ " Change the process ID to avoid the "still running" warning.
+ let swapfile_bytes[24:27] = s:pid_to_blob(s:get_unused_pid(
+ \ s:blob_to_pid(swapfile_bytes[24:27])))
call writefile(swapfile_bytes, swapfile_name)
edit Xtest.scr
" will end up using the same swap file after deleting the existing one
diff --git a/src/version.c b/src/version.c
index a187618c65..d9b197bdc6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2044,
+/**/
2043,
/**/
2042,