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

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

Commit: https://github.com/vim/vim/commit/0912ec20b8e847f0d96be65e7689989edc056b15
Author: h-east <[email protected]>
Date:   Mon Aug 17 04:29:58 2026 +0900

    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.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[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'

-- 
-- 
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/E1wvgn1-007HPs-Vv%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.