Skip to content

Commit 7591116

Browse files
committed
patch 8.2.1260: there is no good test for CursorHold
Problem: There is no good test for CursorHold. Solution: Add a test. Remove duplicated test. (Yegappan Lakshmanan, closes #6503
1 parent f56c95f commit 7591116

4 files changed

Lines changed: 31 additions & 27 deletions

File tree

src/testdir/test_autocmd.vim

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ func Test_vim_did_enter()
1919
" becomes one.
2020
endfunc
2121

22+
" Test for the CursorHold autocmd
23+
func Test_CursorHold_autocmd()
24+
CheckRunVimInTerminal
25+
call writefile(['one', 'two', 'three'], 'Xfile')
26+
let before =<< trim END
27+
set updatetime=10
28+
au CursorHold * call writefile([line('.')], 'Xoutput', 'a')
29+
END
30+
call writefile(before, 'Xinit')
31+
let buf = RunVimInTerminal('-S Xinit Xfile', {})
32+
call term_wait(buf)
33+
call term_sendkeys(buf, "gg")
34+
call term_wait(buf)
35+
sleep 50m
36+
call term_sendkeys(buf, "j")
37+
call term_wait(buf)
38+
sleep 50m
39+
call term_sendkeys(buf, "j")
40+
call term_wait(buf)
41+
sleep 50m
42+
call StopVimInTerminal(buf)
43+
44+
call assert_equal(['1', '2', '3'], readfile('Xoutput')[-3:-1])
45+
46+
call delete('Xinit')
47+
call delete('Xoutput')
48+
call delete('Xfile')
49+
endfunc
50+
2251
if has('timers')
2352

2453
func ExitInsertMode(id)

src/testdir/test_buffer.vim

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ func Test_bunload_with_offset()
6767
call assert_fails('1,4bunload', 'E16:')
6868
call assert_fails(',100bunload', 'E16:')
6969

70-
" Use a try-catch for this test. When assert_fails() is used for this
71-
" test, the command fails with E515: instead of E90:
72-
let caught_E90 = 0
73-
try
74-
$bunload
75-
catch /E90:/
76-
let caught_E90 = 1
77-
endtry
78-
call assert_equal(1, caught_E90)
7970
call assert_fails('$bunload', 'E90:')
8071
endfunc
8172

src/testdir/test_normal.vim

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,24 +2506,6 @@ func Test_normal47_visual_buf_wipe()
25062506
set nomodified
25072507
endfunc
25082508

2509-
func Test_normal47_autocmd()
2510-
" disabled, does not seem to be possible currently
2511-
throw "Skipped: not possible to test cursorhold autocmd while waiting for input in normal_cmd"
2512-
new
2513-
call append(0, repeat('-',20))
2514-
au CursorHold * call feedkeys('2l', '')
2515-
1
2516-
set updatetime=20
2517-
" should delete 12 chars (d12l)
2518-
call feedkeys('d1', '!')
2519-
call assert_equal('--------', getline(1))
2520-
2521-
" clean up
2522-
au! CursorHold
2523-
set updatetime=4000
2524-
bw!
2525-
endfunc
2526-
25272509
func Test_normal48_wincmd()
25282510
new
25292511
exe "norm! \<c-w>c"

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1260,
757759
/**/
758760
1259,
759761
/**/

0 commit comments

Comments
 (0)