!722 [sync] PR-720: fix some tests failed

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2025-04-28 02:50:27 +00:00 committed by Gitee
commit b8cb86c88b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 577 additions and 1 deletions

View File

@ -0,0 +1,443 @@
From e7cda97b6b578b33a42de0d27ac2876337c641ca Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Mon, 29 Aug 2022 11:02:59 +0100
Subject: [PATCH] patch 9.0.0313: using common name in tests leads to flaky
tests
Problem: Using common name in tests leads to flaky tests.
Solution: Rename files and directories to be more specific.
---
src/testdir/test_autochdir.vim | 8 +--
src/testdir/test_autocmd.vim | 50 +++++++-------
src/testdir/test_backup.vim | 6 +-
src/testdir/test_buffer.vim | 116 ++++++++++++++++-----------------
4 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/src/testdir/test_autochdir.vim b/src/testdir/test_autochdir.vim
index 36b4695..332de8f 100644
--- a/src/testdir/test_autochdir.vim
+++ b/src/testdir/test_autochdir.vim
@@ -56,10 +56,10 @@ func Test_acd_win_execute()
set acd
call test_autochdir()
- call mkdir('Xfile')
+ call mkdir('XacdDir')
let winid = win_getid()
- new Xfile/file
- call assert_match('testdir.Xfile$', getcwd())
+ new XacdDir/file
+ call assert_match('testdir.XacdDir$', getcwd())
cd ..
call assert_match('testdir$', getcwd())
call win_execute(winid, 'echo')
@@ -68,7 +68,7 @@ func Test_acd_win_execute()
bwipe!
set noacd
call chdir(cwd)
- call delete('Xfile', 'rf')
+ call delete('XacdDir', 'rf')
endfunc
func Test_verbose_pwd()
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index e251112..952b582 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -24,29 +24,29 @@ endfunc
" Test for the CursorHold autocmd
func Test_CursorHold_autocmd()
CheckRunVimInTerminal
- call writefile(['one', 'two', 'three'], 'Xfile')
+ call writefile(['one', 'two', 'three'], 'XoneTwoThree')
let before =<< trim END
set updatetime=10
- au CursorHold * call writefile([line('.')], 'Xoutput', 'a')
+ au CursorHold * call writefile([line('.')], 'XCHoutput', 'a')
END
- call writefile(before, 'Xinit')
- let buf = RunVimInTerminal('-S Xinit Xfile', {})
+ call writefile(before, 'XCHinit')
+ let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {})
call term_sendkeys(buf, "G")
call term_wait(buf, 50)
call term_sendkeys(buf, "gg")
call term_wait(buf)
- call WaitForAssert({-> assert_equal(['1'], readfile('Xoutput')[-1:-1])})
+ call WaitForAssert({-> assert_equal(['1'], readfile('XCHoutput')[-1:-1])})
call term_sendkeys(buf, "j")
call term_wait(buf)
- call WaitForAssert({-> assert_equal(['1', '2'], readfile('Xoutput')[-2:-1])})
+ call WaitForAssert({-> assert_equal(['1', '2'], readfile('XCHoutput')[-2:-1])})
call term_sendkeys(buf, "j")
call term_wait(buf)
- call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('Xoutput')[-3:-1])})
+ call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])})
call StopVimInTerminal(buf)
- call delete('Xinit')
- call delete('Xoutput')
- call delete('Xfile')
+ call delete('XCHinit')
+ call delete('XCHoutput')
+ call delete('XoneTwoThree')
endfunc
if has('timers')
@@ -1447,21 +1447,21 @@ endfunc
" Test for Bufleave autocommand that deletes the buffer we are about to edit.
func Test_BufleaveWithDelete()
- new | edit Xfile1
+ new | edit XbufLeave1
augroup test_bufleavewithdelete
autocmd!
- autocmd BufLeave Xfile1 bwipe Xfile2
+ autocmd BufLeave XbufLeave1 bwipe XbufLeave2
augroup END
- call assert_fails('edit Xfile2', 'E143:')
- call assert_equal('Xfile1', bufname('%'))
+ call assert_fails('edit XbufLeave2', 'E143:')
+ call assert_equal('XbufLeave1', bufname('%'))
- autocmd! test_bufleavewithdelete BufLeave Xfile1
+ autocmd! test_bufleavewithdelete BufLeave XbufLeave1
augroup! test_bufleavewithdelete
new
- bwipe! Xfile1
+ bwipe! XbufLeave1
endfunc
" Test for autocommand that changes the buffer list, when doing ":ball".
@@ -2893,13 +2893,13 @@ endfunc
func Test_BufReadPre_delfile()
augroup TestAuCmd
au!
- autocmd BufReadPre Xfile call delete('Xfile')
+ autocmd BufReadPre XbufreadPre call delete('XbufreadPre')
augroup END
- call writefile([], 'Xfile')
- call assert_fails('new Xfile', 'E200:')
- call assert_equal('Xfile', @%)
+ call writefile([], 'XbufreadPre')
+ call assert_fails('new XbufreadPre', 'E200:')
+ call assert_equal('XbufreadPre', @%)
call assert_equal(1, &readonly)
- call delete('Xfile')
+ call delete('XbufreadPre')
augroup TestAuCmd
au!
augroup END
@@ -2910,13 +2910,13 @@ endfunc
func Test_BufReadPre_changebuf()
augroup TestAuCmd
au!
- autocmd BufReadPre Xfile edit Xsomeotherfile
+ autocmd BufReadPre Xchangebuf edit Xsomeotherfile
augroup END
- call writefile([], 'Xfile')
- call assert_fails('new Xfile', 'E201:')
+ call writefile([], 'Xchangebuf')
+ call assert_fails('new Xchangebuf', 'E201:')
call assert_equal('Xsomeotherfile', @%)
call assert_equal(1, &readonly)
- call delete('Xfile')
+ call delete('Xchangebuf')
augroup TestAuCmd
au!
augroup END
diff --git a/src/testdir/test_backup.vim b/src/testdir/test_backup.vim
index 4c7abe8..ee4b26f 100644
--- a/src/testdir/test_backup.vim
+++ b/src/testdir/test_backup.vim
@@ -78,11 +78,11 @@ endfunc
" Test for using a non-existing directory as a backup directory
func Test_non_existing_backupdir()
set backupdir=./non_existing_dir backupskip=
- call writefile(['line1'], 'Xfile')
- new Xfile
+ call writefile(['line1'], 'Xbackupdir')
+ new Xbackupdir
call assert_fails('write', 'E510:')
set backupdir&vim backupskip&vim
- call delete('Xfile')
+ call delete('Xbackupdir')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim
index ce99c61..6eda0a6 100644
--- a/src/testdir/test_buffer.vim
+++ b/src/testdir/test_buffer.vim
@@ -76,14 +76,14 @@ func Test_buflist_browse()
%bwipe!
call assert_fails('buffer 1000', 'E86:')
- call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1')
- call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2')
- call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3')
- edit Xfile1
+ call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1')
+ call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2')
+ call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3')
+ edit Xbrowse1
let b1 = bufnr()
- edit Xfile2
+ edit Xbrowse2
let b2 = bufnr()
- edit +/baz4 Xfile3
+ edit +/baz4 Xbrowse3
let b3 = bufnr()
call assert_fails('buffer ' .. b1 .. ' abc', 'E488:')
@@ -127,9 +127,9 @@ func Test_buflist_browse()
call assert_fails('sandbox bnext', 'E48:')
- call delete('Xfile1')
- call delete('Xfile2')
- call delete('Xfile3')
+ call delete('Xbrowse1')
+ call delete('Xbrowse2')
+ call delete('Xbrowse3')
%bwipe!
endfunc
@@ -200,39 +200,39 @@ endfunc
" Test for quitting the 'swapfile exists' dialog with the split buffer
" command.
func Test_buffer_sbuf_cleanup()
- call writefile([], 'Xfile')
+ call writefile([], 'XsplitCleanup')
" first open the file in a buffer
- new Xfile
+ new XsplitCleanup
let bnr = bufnr()
close
" create the swap file
- call writefile([], '.Xfile.swp')
+ call writefile([], '.XsplitCleanup.swp')
" Remove the catch-all that runtest.vim adds
au! SwapExists
augroup BufTest
au!
- autocmd SwapExists Xfile let v:swapchoice='q'
+ autocmd SwapExists XsplitCleanup let v:swapchoice='q'
augroup END
exe 'sbuf ' . bnr
call assert_equal(1, winnr('$'))
- call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+ call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
" test for :sball
sball
call assert_equal(1, winnr('$'))
- call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+ call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
%bw!
set shortmess+=F
let v:statusmsg = ''
- edit Xfile
+ edit XsplitCleanup
call assert_equal('', v:statusmsg)
call assert_equal(1, winnr('$'))
- call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+ call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
set shortmess&
- call delete('Xfile')
- call delete('.Xfile.swp')
+ call delete('XsplitCleanup')
+ call delete('.XsplitCleanup.swp')
augroup BufTest
au!
augroup END
@@ -266,23 +266,23 @@ func Test_goto_buf_with_confirm()
" call do_browse(), which will try to use a GUI file browser,
" which aborts if a GUI is not available.
CheckNotFeature dialog_con_gui
- new Xfile
+ new XgotoConf
enew
call setline(1, 'test')
- call assert_fails('b Xfile', 'E37:')
+ call assert_fails('b XgotoConf', 'E37:')
call feedkeys('c', 'L')
- call assert_fails('confirm b Xfile', 'E37:')
+ call assert_fails('confirm b XgotoConf', 'E37:')
call assert_true(&modified)
call assert_true(empty(bufname('%')))
call feedkeys('y', 'L')
confirm b XgotoConf
- call assert_equal('Xfile', bufname('%'))
+ call assert_equal('XgotoConf', bufname('%'))
call assert_equal(['test'], readfile('Untitled'))
e Untitled
call setline(2, 'test2')
call feedkeys('n', 'L')
- confirm b Xfile
- call assert_equal('Xfile', bufname('%'))
+ confirm b XgotoConf
+ call assert_equal('XgotoConf', bufname('%'))
call assert_equal(['test'], readfile('Untitled'))
call delete('Untitled')
close!
@@ -290,15 +290,15 @@ endfunc
" Test for splitting buffer with 'switchbuf'
func Test_buffer_switchbuf()
- new Xfile
+ new Xswitchbuf
wincmd w
set switchbuf=useopen
- sbuf Xfile
+ sbuf Xswitchbuf
call assert_equal(1, winnr())
call assert_equal(2, winnr('$'))
set switchbuf=usetab
tabnew
- sbuf Xfile
+ sbuf Xswitchbuf
call assert_equal(1, tabpagenr())
call assert_equal(2, tabpagenr('$'))
set switchbuf&
@@ -310,11 +310,11 @@ func Test_bufadd_autocmd_bwipe()
%bw!
augroup BufAdd_Wipe
au!
- autocmd BufAdd Xfile %bw!
+ autocmd BufAdd Xbwipe %bw!
augroup END
- edit Xfile
+ edit Xbwipe
call assert_equal('', @%)
- call assert_equal(0, bufexists('Xfile'))
+ call assert_equal(0, bufexists('Xbwipe'))
augroup BufAdd_Wipe
au!
augroup END
@@ -334,40 +334,40 @@ endfunc
" Test for using CTRL-^ to edit the alternative file keeping the cursor
" position with 'nostartofline'. Also test using the 'buf' command.
func Test_buffer_edit_altfile()
- call writefile(repeat(['one two'], 50), 'Xfile1')
- call writefile(repeat(['five six'], 50), 'Xfile2')
+ call writefile(repeat(['one two'], 50), 'Xaltfile1')
+ call writefile(repeat(['five six'], 50), 'Xaltfile2')
set nosol
- edit Xfile1
+ edit Xaltfile1
call cursor(25, 5)
- edit Xfile2
+ edit Xaltfile2
call cursor(30, 4)
exe "normal \<C-^>"
call assert_equal([0, 25, 5, 0], getpos('.'))
exe "normal \<C-^>"
call assert_equal([0, 30, 4, 0], getpos('.'))
- buf Xfile1
+ buf Xaltfile1
call assert_equal([0, 25, 5, 0], getpos('.'))
- buf Xfile2
+ buf Xaltfile2
call assert_equal([0, 30, 4, 0], getpos('.'))
set sol&
- call delete('Xfile1')
- call delete('Xfile2')
+ call delete('Xaltfile1')
+ call delete('Xaltfile2')
endfunc
" Test for running the :sball command with a maximum window count and a
" modified buffer
func Test_sball_with_count()
%bw!
- edit Xfile1
+ edit Xcountfile1
call setline(1, ['abc'])
- new Xfile2
- new Xfile3
- new Xfile4
+ new Xcountfile2
+ new Xcountfile3
+ new Xcountfile4
2sball
- call assert_equal(bufnr('Xfile4'), winbufnr(1))
- call assert_equal(bufnr('Xfile1'), winbufnr(2))
- call assert_equal(0, getbufinfo('Xfile2')[0].loaded)
- call assert_equal(0, getbufinfo('Xfile3')[0].loaded)
+ call assert_equal(bufnr('Xcountfile4'), winbufnr(1))
+ call assert_equal(bufnr('Xcountfile1'), winbufnr(2))
+ call assert_equal(0, getbufinfo('Xcountfile2')[0].loaded)
+ call assert_equal(0, getbufinfo('Xcountfile3')[0].loaded)
%bw!
endfunc
@@ -460,18 +460,18 @@ endfunc
func Test_buflist_alloc_failure()
%bw!
- edit Xfile1
+ edit XallocFail1
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
- call assert_fails('edit Xfile2', 'E342:')
+ call assert_fails('edit XallocFail2', 'E342:')
" test for bufadd()
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('call bufadd("Xbuffer")', 'E342:')
" test for setting the arglist
- edit Xfile2
+ edit XallocFail2
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
- call assert_fails('next Xfile3', 'E342:')
+ call assert_fails('next XallocFail3', 'E342:')
" test for setting the alternate buffer name when writing a file
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
@@ -498,17 +498,17 @@ func Test_buflist_alloc_failure()
endif
" test for loading a new buffer after wiping out all the buffers
- edit Xfile4
+ edit XallocFail4
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('%bw!', 'E342:')
" test for :checktime loading the buffer
- call writefile(['one'], 'Xfile5')
+ call writefile(['one'], 'XallocFail5')
if has('unix')
- edit Xfile5
+ edit XallocFail5
" sleep for some time to make sure the timestamp is different
sleep 200m
- call writefile(['two'], 'Xfile5')
+ call writefile(['two'], 'XallocFail5')
set autoread
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('checktime', 'E342:')
@@ -518,12 +518,12 @@ func Test_buflist_alloc_failure()
" test for :vimgrep loading a dummy buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
- call assert_fails('vimgrep two Xfile5', 'E342:')
- call delete('Xfile5')
+ call assert_fails('vimgrep two XallocFail5', 'E342:')
+ call delete('XallocFail5')
" test for quickfix command loading a buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
- call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:')
+ call assert_fails('cexpr "XallocFail6:10:Line10"', 'E342:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
--
2.33.0

View File

@ -0,0 +1,35 @@
From fb3f9699362f8d51c3b48fcaea1eb2ed16c81454 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <cb@256bit.org>
Date: Sun, 11 Aug 2024 20:09:17 +0200
Subject: [PATCH] Problem: crash with WinNewPre autocommand
Problem: crash with WinNewPre autocommand, because window
structures are not yet safe to use
Solution: Don't trigger WinNewPre on :tabnew
Signed-off-by: Christian Brabandt <cb@256bit.org>
---
src/testdir/test_autocmd.vim | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index e251112..3df3af1 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -14,6 +14,13 @@ func s:cleanup_buffers() abort
endfor
endfunc
+func CleanUpTestAuGroup()
+ augroup testing
+ au!
+ augroup END
+ augroup! testing
+endfunc
+
func Test_vim_did_enter()
call assert_false(v:vim_did_enter)
--
2.33.0

View File

@ -0,0 +1,29 @@
From 44c1c04ddb000bd03c6e8851dcdef07fd8c329ff Mon Sep 17 00:00:00 2001
From: Christian Brabandt <cb@256bit.org>
Date: Mon, 17 Feb 2025 22:26:00 +0100
Subject: [PATCH] patch 9.1.1120: tests: Test_registers fails
Problem: tests: Test_registers fails
(T.J. Townsend, after v9.1.1115)
Solution: require clipboard feature
Signed-off-by: Christian Brabandt <cb@256bit.org>
---
src/testdir/test_registers.vim | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
index e0b9aa2..e748e8c 100644
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -869,6 +869,7 @@ endfunc
" This caused use-after-free
func Test_register_redir_display()
+ CheckFeature clipboard
" don't touch the clipboard, so only perform this, when the clipboard is not working
if has("clipboard_working")
throw "Skipped: skip touching the clipboard register!"
--
2.33.0

View File

@ -0,0 +1,59 @@
From 919addfdcd0ef3f7b662dc9e32beb1c4da3d77bf Mon Sep 17 00:00:00 2001
From: wjiang <app@cameyan.com>
Date: Thu, 3 Apr 2025 14:07:33 +0800
Subject: [PATCH] fix Test_autocmd_BufWinLeave_with_vsp and Test_tag_stack
---
src/testdir/test_autocmd.vim | 5 +++--
src/testdir/test_tagjump.vim | 5 ++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index cea5e41..580a14d 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -3647,8 +3647,6 @@ func Test_autocmd_BufWinLeave_with_vsp()
let dummy = 'XXXDummy.txt'
call writefile([], fname)
call writefile([], dummy)
- defer delete(fname)
- defer delete(dummy)
exe "e " fname
vsp
augroup testing
@@ -3657,6 +3655,9 @@ func Test_autocmd_BufWinLeave_with_vsp()
bw
call CleanUpTestAuGroup()
exe "bw! " .. dummy
+
+ call delete(fname)
+ call delete(dummy)
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim
index 7de1926..b2d962f 100644
--- a/src/testdir/test_tagjump.vim
+++ b/src/testdir/test_tagjump.vim
@@ -994,9 +994,6 @@ func Test_tag_stack()
call settagstack(1, {'items' : []})
call assert_fails('pop', 'E73:')
- call delete('Xtags')
- call delete('Xfoo')
-
" References to wiped buffer are deleted.
for i in range(10, 20)
edit Xtest
@@ -1014,6 +1011,8 @@ func Test_tag_stack()
call assert_equal(0, t.length)
call assert_equal(1, t.curidx)
+ call delete('Xtags')
+ call delete('Xfoo')
set tags&
%bwipe
endfunc
--
2.33.0

View File

@ -12,7 +12,7 @@
Name: vim
Epoch: 2
Version: 9.0
Release: 33
Release: 34
Summary: Vim is a highly configurable text editor for efficiently creating and changing any kind of text.
License: Vim and MIT
URL: http://www.vim.org
@ -138,10 +138,14 @@ Patch6108: backport-runtime-escape-on-Unix-as-well.patch
Patch6109: backport-runtime-Fix-for-FreeBSD-unzip-command.patch
Patch6110: backport-runtime-zip-plugin-has-problems-with-special.patch
Patch6111: backport-CVE-2025-29768.patch
Patch6112: backport-patch-9.0.0313-using-common-name-in-tests-leads-to-flaky-tests.patch
Patch6113: backport-patch-9.1.0671-crash-with-WinNewPre-autocommand.patch
Patch6114: backport-patch-9.1.1120-fix-Test_registers-fails.patch
Patch9000: bugfix-rm-modify-info-version.patch
Patch9001: vim-Add-sw64-architecture.patch
Patch9002: fix-CVE-2024-47814.patch
Patch9003: fix-autocmd_BufWinLeave_with_vsp-and-tag_stack.patch
BuildRequires: autoconf python3-devel ncurses-devel gettext perl-devel perl-generators gcc
BuildRequires: perl(ExtUtils::Embed) perl(ExtUtils::ParseXS) libacl-devel gpm-devel file
@ -549,6 +553,12 @@ LANG=en_US.UTF-8 make -j1 test
%{_mandir}/man1/evim.*
%changelog
* Thu Apr 03 2025 wangjiang <app@cameyan.com> - 2:9.0-34
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix some tests failed
* Tue Mar 18 2025 wangjiang <app@cameyan.com> - 2:9.0-33
- Type:CVE
- ID:CVE-2025-29768