Patch 8.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)
Files: .github/workflows/ci-windows.yaml, src/testdir/test_swap.vim
*** ../vim-8.2.2043/.github/workflows/ci-windows.yaml 2020-10-22
17:33:12.469081986 +0200
--- .github/workflows/ci-windows.yaml 2020-11-25 12:38:09.349357732 +0100
***************
*** 215,221 ****
:: Wait about 10 minutes.
for /L %%i in (1,1,60) do (
if exist done.txt goto exitloop
! timeout 10
)
set timeout=1
:exitloop
--- 215,222 ----
:: Wait about 10 minutes.
for /L %%i in (1,1,60) do (
if exist done.txt goto exitloop
! timeout 10 > NUL 2>&1
! if ERRORLEVEL 1 ping -n 11 localhost > NUL
)
set timeout=1
:exitloop
*** ../vim-8.2.2043/src/testdir/test_swap.vim 2020-11-20 09:10:11.427730168
+0100
--- src/testdir/test_swap.vim 2020-11-25 12:38:09.349357732 +0100
***************
*** 403,408 ****
--- 403,441 ----
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,424 ****
" 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
call writefile(swapfile_bytes, swapfile_name)
edit Xtest.scr
" will end up using the same swap file after deleting the existing one
--- 449,457 ----
" 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.
! 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
*** ../vim-8.2.2043/src/version.c 2020-11-25 12:25:42.919981195 +0100
--- src/version.c 2020-11-25 12:41:32.029008035 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2044,
/**/
--
GUARD #1: What, ridden on a horse?
ARTHUR: Yes!
GUARD #1: You're using coconuts!
ARTHUR: What?
GUARD #1: You've got two empty halves of coconut and you're bangin' 'em
together.
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202011251144.0APBiEDl2022787%40masaka.moolenaar.net.