To: vim_dev@googlegroups.com Subject: Patch 8.1.0428 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0428 Problem: The :suspend command is not tested. Solution: Add a test. (Dominique Pelle, closes #3472) Files: src/Make_all.mak, src/testdir/test_alot.vim, src/testdir/test_suspend.vim *** ../vim-8.1.0427/src/Make_all.mak 2018-09-14 20:10:15.874499472 +0200 --- src/Make_all.mak 2018-09-22 21:27:23.453506886 +0200 *************** *** 168,173 **** --- 168,174 ---- test_stat \ test_statusline \ test_substitute \ + test_suspend \ test_swap \ test_syn_attr \ test_syntax \ *** ../vim-8.1.0427/src/testdir/test_alot.vim 2018-09-14 20:10:15.874499472 +0200 --- src/testdir/test_alot.vim 2018-09-22 21:27:23.453506886 +0200 *************** *** 52,57 **** --- 52,58 ---- source test_sort.vim source test_sha256.vim source test_statusline.vim + source test_suspend.vim source test_syn_attr.vim source test_tabline.vim source test_tabpage.vim *** ../vim-8.1.0427/src/testdir/test_suspend.vim 2018-09-22 21:36:00.066330569 +0200 --- src/testdir/test_suspend.vim 2018-09-22 21:27:23.453506886 +0200 *************** *** 0 **** --- 1,51 ---- + " Test :suspend + + source shared.vim + + 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, v:progpath + \ . " --clean -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 WaitForAssert({-> assert_match('$ $', term_getline(buf, '.'))}) + + " Without 'autowrite', buffer should not be written. + call assert_equal(0, filereadable('Xfoo')) + + call term_sendkeys(buf, "fg\") + call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) + 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 WaitForAssert({-> assert_match('$ $', term_getline(buf, '.'))}) + call assert_equal(['foo'], readfile('Xfoo')) + call term_sendkeys(buf, "fg\") + call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))}) + + exe buf . 'bwipe!' + call delete('Xfoo') + set autowrite& + endfunc *** ../vim-8.1.0427/src/version.c 2018-09-22 14:39:07.681593221 +0200 --- src/version.c 2018-09-22 21:29:51.436437049 +0200 *************** *** 796,797 **** --- 796,799 ---- { /* Add new patch number below this line */ + /**/ + 428, /**/ -- From "know your smileys": [:-) Frankenstein's monster /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///