• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision94656f3ff3049a6d4ffed437b74d5c51ed3417d3 (tree)
l'heure2020-11-25 20:45:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.2044: MS-Windows: swap file test sometimes fails

Commit: https://github.com/vim/vim/commit/5ee0981fb5259f94900ab25207caddf1fa61010d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Nov 25 12:43:28 2020 +0100

patch 8.2.2044: MS-Windows: swap file test sometimes fails
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)

Change Summary

Modification

diff -r 1d635e77266d -r 94656f3ff304 .github/workflows/ci-windows.yaml
--- a/.github/workflows/ci-windows.yaml Wed Nov 25 12:30:04 2020 +0100
+++ b/.github/workflows/ci-windows.yaml Wed Nov 25 12:45:03 2020 +0100
@@ -215,7 +215,8 @@
215215 :: Wait about 10 minutes.
216216 for /L %%i in (1,1,60) do (
217217 if exist done.txt goto exitloop
218- timeout 10
218+ timeout 10 > NUL 2>&1
219+ if ERRORLEVEL 1 ping -n 11 localhost > NUL
219220 )
220221 set timeout=1
221222 :exitloop
diff -r 1d635e77266d -r 94656f3ff304 src/testdir/test_swap.vim
--- a/src/testdir/test_swap.vim Wed Nov 25 12:30:04 2020 +0100
+++ b/src/testdir/test_swap.vim Wed Nov 25 12:45:03 2020 +0100
@@ -403,6 +403,39 @@
403403 call delete('Xswapdir', 'rf')
404404 endfunc
405405
406+func s:get_unused_pid(base)
407+ if has('job')
408+ " Execute 'echo' as a temporary job, and return its pid as an unused pid.
409+ if has('win32')
410+ let cmd = 'cmd /c echo'
411+ else
412+ let cmd = 'echo'
413+ endif
414+ let j = job_start(cmd)
415+ while job_status(j) ==# 'run'
416+ sleep 10m
417+ endwhile
418+ if job_status(j) ==# 'dead'
419+ return job_info(j).process
420+ endif
421+ endif
422+ " Must add four for MS-Windows to see it as a different one.
423+ return a:base + 4
424+endfunc
425+
426+func s:blob_to_pid(b)
427+ return a:b[3] * 16777216 + a:b[2] * 65536 + a:b[1] * 256 + a:b[0]
428+endfunc
429+
430+func s:pid_to_blob(i)
431+ let b = 0z
432+ let b[0] = and(a:i, 0xff)
433+ let b[1] = and(a:i / 256, 0xff)
434+ let b[2] = and(a:i / 65536, 0xff)
435+ let b[3] = and(a:i / 16777216, 0xff)
436+ return b
437+endfunc
438+
406439 func Test_swap_auto_delete()
407440 " Create a valid swapfile by editing a file with a special extension.
408441 split Xtest.scr
@@ -416,9 +449,9 @@
416449 " Forget about the file, recreate the swap file, then edit it again. The
417450 " swap file should be automatically deleted.
418451 bwipe!
419- " Change the process ID to avoid the "still running" warning. Must add four
420- " for MS-Windows to see it as a different one.
421- let swapfile_bytes[24] = swapfile_bytes[24] + 4
452+ " Change the process ID to avoid the "still running" warning.
453+ let swapfile_bytes[24:27] = s:pid_to_blob(s:get_unused_pid(
454+ \ s:blob_to_pid(swapfile_bytes[24:27])))
422455 call writefile(swapfile_bytes, swapfile_name)
423456 edit Xtest.scr
424457 " will end up using the same swap file after deleting the existing one
diff -r 1d635e77266d -r 94656f3ff304 src/version.c
--- a/src/version.c Wed Nov 25 12:30:04 2020 +0100
+++ b/src/version.c Wed Nov 25 12:45:03 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2044,
755+/**/
754756 2043,
755757 /**/
756758 2042,
Afficher sur ancien navigateur de dépôt.