1
0
forked from aniani/vim

patch 8.2.2105: sound test is a bit flaky

Problem:    Sound test is a bit flaky.
Solution:   Use WaitForAssert(). (Dominique Pellé, closes #7429)
This commit is contained in:
Bram Moolenaar
2020-12-06 21:43:44 +01:00
parent d5a986f460
commit 7b130b9738
2 changed files with 10 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
" Tests for the sound feature " Tests for the sound feature
source shared.vim
if !has('sound') if !has('sound')
throw 'Skipped: sound feature not available' throw 'Skipped: sound feature not available'
endif endif
@@ -13,6 +15,7 @@ func Test_play_event()
if has('win32') if has('win32')
throw 'Skipped: Playing event with callback is not supported on Windows' throw 'Skipped: Playing event with callback is not supported on Windows'
endif endif
let g:id = 0
let id = 'bell'->sound_playevent('PlayCallback') let id = 'bell'->sound_playevent('PlayCallback')
if id == 0 if id == 0
throw 'Skipped: bell event not available' throw 'Skipped: bell event not available'
@@ -20,8 +23,7 @@ func Test_play_event()
" Stop it quickly, avoid annoying the user. " Stop it quickly, avoid annoying the user.
sleep 20m sleep 20m
eval id->sound_stop() eval id->sound_stop()
sleep 30m call WaitForAssert({-> assert_equal(id, g:id)})
call assert_equal(id, g:id)
call assert_equal(1, g:result) " sound was aborted call assert_equal(1, g:result) " sound was aborted
endfunc endfunc
@@ -37,17 +39,15 @@ func Test_play_silent()
" play until the end " play until the end
let id2 = fname->sound_playfile('PlayCallback') let id2 = fname->sound_playfile('PlayCallback')
call assert_true(id2 > 0) call assert_true(id2 > 0)
sleep 500m call WaitForAssert({-> assert_equal(id2, g:id)})
call assert_equal(id2, g:id)
call assert_equal(0, g:result) call assert_equal(0, g:result)
let id2 = sound_playfile(fname, 'PlayCallback') let id2 = sound_playfile(fname, 'PlayCallback')
call assert_true(id2 > 0) call assert_true(id2 > 0)
sleep 20m sleep 20m
call sound_clear() call sound_clear()
sleep 30m call WaitForAssert({-> assert_equal(id2, g:id)})
call assert_equal(id2, g:id) call assert_equal(1, g:result) " sound was aborted
call assert_equal(1, g:result)
" recursive use was causing a crash " recursive use was causing a crash
func PlayAgain(id, fname) func PlayAgain(id, fname)
@@ -59,8 +59,7 @@ func Test_play_silent()
call assert_true(id3 > 0) call assert_true(id3 > 0)
sleep 50m sleep 50m
call sound_clear() call sound_clear()
sleep 30m call WaitForAssert({-> assert_true(g:id > 0)})
call assert_true(g:id_again > 0)
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2105,
/**/ /**/
2104, 2104,
/**/ /**/