From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- test/old/testdir/test_suspend.vim | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/old/testdir/test_suspend.vim (limited to 'test/old/testdir/test_suspend.vim') diff --git a/test/old/testdir/test_suspend.vim b/test/old/testdir/test_suspend.vim new file mode 100644 index 0000000000..bf88bd4453 --- /dev/null +++ b/test/old/testdir/test_suspend.vim @@ -0,0 +1,63 @@ +" Test :suspend + +source shared.vim +source term_util.vim + +func CheckSuspended(buf, fileExists) + call WaitForAssert({-> assert_match('[$#] $', term_getline(a:buf, '.'))}) + + if a:fileExists + call assert_equal(['foo'], readfile('Xfoo')) + else + " Without 'autowrite', buffer should not be written. + call assert_equal(0, filereadable('Xfoo')) + endif + + call term_sendkeys(a:buf, "fg\\") + call WaitForAssert({-> assert_equal(' 1 foo', term_getline(a:buf, '.'))}) +endfunc + +func Test_suspend() + if !has('terminal') || !executable('/bin/sh') + return + endif + + let buf = term_start('/bin/sh') + " Wait for shell prompt. + call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) + + call term_sendkeys(buf, GetVimCommandClean() + \ . " -X" + \ . " -c 'set nu'" + \ . " -c 'call setline(1, \"foo\")'" + \ . " Xfoo\") + " Cursor in terminal buffer should be on first line in spawned vim. + call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) + + for suspend_cmd in [":suspend\", + \ ":stop\", + \ ":suspend!\", + \ ":stop!\", + \ "\"] + " Suspend and wait for shell prompt. + call term_sendkeys(buf, suspend_cmd) + call CheckSuspended(buf, 0) + endfor + + " Test that :suspend! with 'autowrite' writes content of buffers if modified. + call term_sendkeys(buf, ":set autowrite\") + call assert_equal(0, filereadable('Xfoo')) + call term_sendkeys(buf, ":suspend\") + " Wait for shell prompt. + call CheckSuspended(buf, 1) + + " Quit gracefully to dump coverage information. + call term_sendkeys(buf, ":qall!\") + call term_wait(buf) + " Wait until Vim actually exited and shell shows a prompt + call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) + call StopShellInTerminal(buf) + + exe buf . 'bwipe!' + call delete('Xfoo') +endfunc -- cgit From ff801ce7f728ea51cec3328328ac41d98d545725 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 14:59:52 +0800 Subject: vim-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 vim/vim#5899) Halve the initial times to make tests run faster when there is no rerun. https://github.com/vim/vim/commit/6a2c5a7dd5c9215cc030d5ea6e4616d782c091dd Co-authored-by: Bram Moolenaar --- test/old/testdir/test_suspend.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/old/testdir/test_suspend.vim') diff --git a/test/old/testdir/test_suspend.vim b/test/old/testdir/test_suspend.vim index bf88bd4453..aa6603be78 100644 --- a/test/old/testdir/test_suspend.vim +++ b/test/old/testdir/test_suspend.vim @@ -53,7 +53,7 @@ func Test_suspend() " Quit gracefully to dump coverage information. call term_sendkeys(buf, ":qall!\") - call term_wait(buf) + call TermWait(buf) " Wait until Vim actually exited and shell shows a prompt call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) call StopShellInTerminal(buf) -- cgit