Commit: patch 9.2.0959: tests: Test_xrestore() is flaky and cannot recover

Christian Brabandt <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0959: tests: Test_xrestore() is flaky and cannot recover

Commit: https://github.com/vim/vim/commit/d8b0e5bd4a8072675668eb16402d065e9f9903b3
Author: Hirohito Higashi <[email protected]>
Date:   Mon Aug 17 18:53:47 2026 +0000

    patch 9.2.0959: tests: Test_xrestore() is flaky and cannot recover
    
    Problem:  Test_xrestore() fails on CI and the retry fails as well, because
              the retry runs in the same Vim and the connection to the X server
              was not restored.
    Solution: Restore the display in a "finally" block.  Wait for the selection
              to become available instead of failing with E353.
    
    closes: #21066
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Signed-off-by: Hirohito Higashi <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
index bd87e3be7..0daa5fe58 100644
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -176,6 +176,9 @@ endfunc
 func CheckCopyPaste()
   call setline(1, ['copy this', ''])
   normal 1G0"*y$
+  " The selection may not be available right away after connecting to the X
+  " server, the put below would then throw E353.
+  call WaitForAssert({-> assert_equal('copy this', getreg('*'))})
   normal j"*p
   call assert_equal('copy this', getline(2))
 endfunc
@@ -186,15 +189,20 @@ func Test_xrestore()
 
   let display = $DISPLAY
   new
-  call CheckCopyPaste()
-
-  xrestore
-  call CheckCopyPaste()
-
-  exe "xrestore " .. display
-  call CheckCopyPaste()
-
-  bwipe!
+  " Restore the display even when a check fails, otherwise the retry runs
+  " without a connection to the X server.
+  try
+    call CheckCopyPaste()
+
+    xrestore
+    call CheckCopyPaste()
+
+    exe "xrestore " .. display
+    call CheckCopyPaste()
+  finally
+    exe "xrestore " .. display
+    bwipe!
+  endtry
 endfunc
 
 " Test for 'pastetoggle'
diff --git a/src/version.c b/src/version.c
index 9be27f5a3..65bfaa6f0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    959,
 /**/
     958,
 /**/

-- 
-- 
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 visit https://groups.google.com/d/msgid/vim_dev/E1ww2nY-008wKE-QT%40256bit.org.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.