diff src/testdir/test_terminal.vim @ 15186:2b15ee496cbd v8.1.0603

patch 8.1.0603: the :stop command is not tested commit https://github.com/vim/vim/commit/e751a5f531c1ceb58dacc7c280fdaae0df2c71c7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 16 16:16:10 2018 +0100 patch 8.1.0603: the :stop command is not tested Problem: The :stop command is not tested. Solution: Test :stop using a terminal window.
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Dec 2018 16:30:06 +0100
parents efd7bace40f4
children 49bc670c3ee9
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1683,3 +1683,34 @@ func Test_terminal_does_not_truncate_las
 
   call delete('Xfile')
 endfunc
+
+func Test_stop_in_terminal()
+  " We can't expect this to work on all systems, just test on Linux for now.
+  if !has('unix') || system('uname') !~ 'Linux'
+    return
+  endif
+  term /bin/sh
+  let bufnr = bufnr('')
+  call WaitForAssert({-> assert_equal('running', term_getstatus(bufnr))})
+  let lastrow = term_getsize(bufnr)[0]
+
+  call term_sendkeys(bufnr, GetVimCommandClean() . "\r")
+  call term_sendkeys(bufnr, ":echo 'ready'\r")
+  call WaitForAssert({-> assert_match('ready', Get_terminal_text(bufnr, lastrow))})
+
+  call term_sendkeys(bufnr, ":stop\r")
+  " Not sure where "Stopped" shows up, assume in the first three lines.
+  call WaitForAssert({-> assert_match('Stopped',
+	\ Get_terminal_text(bufnr, 1) . 
+	\ Get_terminal_text(bufnr, 2) . 
+	\ Get_terminal_text(bufnr, 3))})
+
+  call term_sendkeys(bufnr, "fg\r")
+  call term_sendkeys(bufnr, ":echo 'back again'\r")
+  call WaitForAssert({-> assert_match('back again', Get_terminal_text(bufnr, lastrow))})
+
+  call term_sendkeys(bufnr, ":quit\r")
+  call term_wait(bufnr)
+  call Stop_shell_in_terminal(bufnr)
+  exe bufnr . 'bwipe'
+endfunc