From dff515205c34bcd054f783aa999ddf76966b7470 Mon Sep 17 00:00:00 2001 From: Yinzuo Jiang Date: Sat, 14 Mar 2026 12:49:26 +0800 Subject: [PATCH] vim-patch:partial:9.1.0613: tests: termdebug test may fail and leave file around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: tests: termdebug test may fail and leave temp file around (Dominique Pellé) Solution: only run balloon_show() if the function exists, validate termdebug is running using the g: termdebug_is_running var, use defer to delete temporary files Only include: - guard balloon_show() in the termdebug plugin - wait for g:termdebug_is_running in Test_termdebug_basic() The remaining upstream test cleanups do not apply here. fixes: vim/vim#15334 https://github.com/vim/vim/commit/2979cfc2627d76a9c09cad46a1647dcd4aa73f5f Co-authored-by: Christian Brabandt AI-assisted: Codex --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 7 ++++++- test/old/testdir/test_plugin_termdebug.vim | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 8d125e07dc..021693e5a1 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -69,6 +69,9 @@ set cpo&vim command -nargs=* -complete=file -bang Termdebug call s:StartDebug(0, ) command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(0, ) +" Keep track of whether Termdebug is running for tests and users. +let g:termdebug_is_running = v:false + let s:pc_id = 12 let s:asm_id = 13 let s:break_id = 14 " breakpoint number is added to this @@ -137,7 +140,7 @@ func s:StartDebugCommand(bang, ...) endfunc func s:StartDebug_internal(dict) - if exists('s:gdbwin') + if get(g:, 'termdebug_is_running', v:false) || exists('s:gdbwin') call s:Echoerr('Terminal debugger already running, cannot run two') return endif @@ -223,6 +226,7 @@ func s:StartDebug_internal(dict) if exists('#User#TermdebugStartPost') doauto User TermdebugStartPost endif + let g:termdebug_is_running = v:true endfunc " Use when debugger didn't start or ended. @@ -816,6 +820,7 @@ func s:EndDebugCommon() endif au! TermDebug + let g:termdebug_is_running = v:false endfunc func s:EndPromptDebug(job_id, exit_code, event) diff --git a/test/old/testdir/test_plugin_termdebug.vim b/test/old/testdir/test_plugin_termdebug.vim index e93673136d..860a639dc0 100644 --- a/test/old/testdir/test_plugin_termdebug.vim +++ b/test/old/testdir/test_plugin_termdebug.vim @@ -63,6 +63,7 @@ func Test_termdebug_basic() edit XTD_basic.c Termdebug ./XTD_basic + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) let gdb_buf = winbufnr(1) wincmd b @@ -196,6 +197,7 @@ func Test_termdebug_basic() let g:termdebug_config = {} let g:termdebug_config['use_prompt'] = use_prompt TermdebugCommand ./XTD_basic arg args + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) wincmd t quit! @@ -218,6 +220,7 @@ func Test_termdebug_tbreak() execute 'edit ' .. src_name execute 'Termdebug ./' .. bin_name + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) let gdb_buf = winbufnr(1) wincmd b @@ -279,6 +282,7 @@ func Test_termdebug_mapping() call assert_true(maparg('-', 'n', 0, 1)->empty()) call assert_true(maparg('+', 'n', 0, 1)->empty()) Termdebug + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) wincmd b call assert_false(maparg('K', 'n', 0, 1)->empty()) @@ -301,6 +305,7 @@ func Test_termdebug_mapping() nnoremap - :echom "-" nnoremap + :echom "+" Termdebug + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) wincmd b call assert_false(maparg('K', 'n', 0, 1)->empty()) @@ -338,6 +343,7 @@ func Test_termdebug_mapping() " Start termdebug from foo buffer foo Termdebug + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) wincmd b call assert_true(maparg('K', 'n', 0, 1).buffer) @@ -440,6 +446,7 @@ function Test_termdebug_save_restore_variables() let g:termdebug_config['map_K'] = 1 Termdebug + call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))}) call WaitForAssert({-> assert_equal(3, winnr('$'))}) call WaitForAssert({-> assert_match(&mousemodel, 'popup_setpos')}) wincmd t