]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0941: tests: clipboard tests fail in the GUI when the terminal has no clipboard v9.2.0941
authorHirohito Higashi <h.east.727@gmail.com>
Tue, 11 Aug 2026 19:27:07 +0000 (19:27 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 11 Aug 2026 19:27:07 +0000 (19:27 +0000)
Problem:  Tests that need the clipboard in a Vim started with
          RunVimInTerminal() are not skipped when only the Vim running the
          tests has a clipboard, which is always the case in the GUI.
Solution: Add CheckClipboardInTerminal to ask a Vim started the same way
          whether it can use the clipboard. (Hirohito Higashi).

closes: #21008

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_hlsearch.vim
src/testdir/test_popupwin.vim
src/testdir/util/check.vim
src/version.c

index 8bf7f0aaeb59f5873082127bc60d398a35e211bc..df54b8b892a64af71bb10a4f5db973706a0fa23f 100644 (file)
@@ -95,6 +95,7 @@ func Test_hlsearch_clipboard()
   CheckScreendump
   CheckRunVimInTerminal
   CheckFeature clipboard_working
+  CheckClipboardInTerminal
 
   let lines =<< trim END
       set incsearch hlsearch
index 61af5e050af4de873681bec8386286629d2a4274..e751d82dcdfcffa4ec26d21d92475be45cf66bb8 100644 (file)
@@ -921,6 +921,7 @@ endfunc
 func Test_popup_select()
   CheckScreendump
   CheckFeature clipboard_working
+  CheckClipboardInTerminal
 
   " create a popup with some text to be selected
   let lines =<< trim END
index 47fea7edf3ddefd5d1282cc22d2f93603bc9f52f..7400563f5ced7139ec76fc03b25e4d47ca03c9b3 100644 (file)
@@ -193,6 +193,25 @@ func CheckRunVimInTerminal()
   endif
 endfunc
 
+" Command to check that the Vim started by RunVimInTerminal() can use the
+" clipboard.  Checking 'clipboard_working' of the Vim that runs the tests is
+" not enough: in the GUI that Vim always has a clipboard, while the Vim
+" started in a terminal window may not have one.
+command CheckClipboardInTerminal call CheckClipboardInTerminal()
+func CheckClipboardInTerminal()
+  if !exists('s:clipboard_in_terminal')
+    call delete('Xclipcheck')
+    " "-v" is needed because in a GUI test run the command from "vimcmd"
+    " starts the GUI, which always has a clipboard.
+    call RunVim([], ['call writefile([has("clipboard_working")], "Xclipcheck")', 'qall!'], '-v')
+    let s:clipboard_in_terminal = filereadable('Xclipcheck') && readfile('Xclipcheck')->get(0, '0') == '1'
+    call delete('Xclipcheck')
+  endif
+  if !s:clipboard_in_terminal
+    throw 'Skipped: Vim in a terminal window cannot use the clipboard'
+  endif
+endfunc
+
 " Command to check that we can run the GUI
 command CheckCanRunGui call CheckCanRunGui()
 func CheckCanRunGui()
index 5ea5c96e229e36e308705187e8c08ef5a766afeb..103220d09f99d3ca4d17354f33923af2a6484965 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    941,
 /**/
     940,
 /**/