comparison src/testdir/test_functions.vim @ 19954:c087099e9163 v8.2.0533

patch 8.2.0533: tests using term_wait() can still be flaky Commit: https://github.com/vim/vim/commit/6a2c5a7dd5c9215cc030d5ea6e4616d782c091dd Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 8 21:50:25 2020 +0200 patch 8.2.0533: tests using term_wait() can still be flaky Problem: Tests using term_wait() can still be flaky. Solution: Increase the wait time when rerunning a test. (James McCoy, closes #5899) Halve the initial times to make tests run faster when there is no rerun.
author Bram Moolenaar <Bram@vim.org>
date Wed, 08 Apr 2020 22:00:05 +0200
parents 82ea10d554fb
children e82996ad131f
comparison
equal deleted inserted replaced
19953:313ad6f6fdb5 19954:c087099e9163
1856 endfunc 1856 endfunc
1857 1857
1858 func Test_state() 1858 func Test_state()
1859 CheckRunVimInTerminal 1859 CheckRunVimInTerminal
1860 1860
1861 " In the first run try a short wait time. If the test fails retry with a
1862 " longer wait time.
1863 if g:run_nr == 1
1864 let wait_time = 50
1865 elseif g:run_nr == 2
1866 let wait_time = 200
1867 else
1868 let wait_time = 500
1869 endif
1870 let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>" 1861 let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
1871 1862
1872 let lines =<< trim END 1863 let lines =<< trim END
1873 call setline(1, ['one', 'two', 'three']) 1864 call setline(1, ['one', 'two', 'three'])
1874 map ;; gg 1865 map ;; gg
1886 call WaitForAssert({-> assert_match('state: S; mode: n', term_getline(buf, 6))}, 1000) 1877 call WaitForAssert({-> assert_match('state: S; mode: n', term_getline(buf, 6))}, 1000)
1887 call term_sendkeys(buf, ":\<CR>") 1878 call term_sendkeys(buf, ":\<CR>")
1888 1879
1889 " Using a timer callback 1880 " Using a timer callback
1890 call term_sendkeys(buf, ":call RunTimer()\<CR>") 1881 call term_sendkeys(buf, ":call RunTimer()\<CR>")
1891 call term_wait(buf, wait_time) 1882 call TermWait(buf, 25)
1892 call term_sendkeys(buf, getstate) 1883 call term_sendkeys(buf, getstate)
1893 call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 6))}, 1000) 1884 call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 6))}, 1000)
1894 1885
1895 " Halfway a mapping 1886 " Halfway a mapping
1896 call term_sendkeys(buf, ":call RunTimer()\<CR>;") 1887 call term_sendkeys(buf, ":call RunTimer()\<CR>;")
1897 call term_wait(buf, wait_time) 1888 call TermWait(buf, 25)
1898 call term_sendkeys(buf, ";") 1889 call term_sendkeys(buf, ";")
1899 call term_sendkeys(buf, getstate) 1890 call term_sendkeys(buf, getstate)
1900 call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000) 1891 call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000)
1901 1892
1902 " Insert mode completion (bit slower on Mac) 1893 " Insert mode completion (bit slower on Mac)
1903 call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>") 1894 call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
1904 call term_wait(buf, wait_time) 1895 call TermWait(buf, 25)
1905 call term_sendkeys(buf, "\<Esc>") 1896 call term_sendkeys(buf, "\<Esc>")
1906 call term_sendkeys(buf, getstate) 1897 call term_sendkeys(buf, getstate)
1907 call WaitForAssert({-> assert_match('state: aSc; mode: i', term_getline(buf, 6))}, 1000) 1898 call WaitForAssert({-> assert_match('state: aSc; mode: i', term_getline(buf, 6))}, 1000)
1908 1899
1909 " Autocommand executing 1900 " Autocommand executing
1910 call term_sendkeys(buf, ":set filetype=foobar\<CR>") 1901 call term_sendkeys(buf, ":set filetype=foobar\<CR>")
1911 call term_wait(buf, wait_time) 1902 call TermWait(buf, 25)
1912 call term_sendkeys(buf, getstate) 1903 call term_sendkeys(buf, getstate)
1913 call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 6))}, 1000) 1904 call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 6))}, 1000)
1914 1905
1915 " Todo: "w" - waiting for ch_evalexpr() 1906 " Todo: "w" - waiting for ch_evalexpr()
1916 1907
1917 " messages scrolled 1908 " messages scrolled
1918 call term_sendkeys(buf, ":call RunTimer()\<CR>:echo \"one\\ntwo\\nthree\"\<CR>") 1909 call term_sendkeys(buf, ":call RunTimer()\<CR>:echo \"one\\ntwo\\nthree\"\<CR>")
1919 call term_wait(buf, wait_time) 1910 call TermWait(buf, 25)
1920 call term_sendkeys(buf, "\<CR>") 1911 call term_sendkeys(buf, "\<CR>")
1921 call term_sendkeys(buf, getstate) 1912 call term_sendkeys(buf, getstate)
1922 call WaitForAssert({-> assert_match('state: Scs; mode: r', term_getline(buf, 6))}, 1000) 1913 call WaitForAssert({-> assert_match('state: Scs; mode: r', term_getline(buf, 6))}, 1000)
1923 1914
1924 call StopVimInTerminal(buf) 1915 call StopVimInTerminal(buf)