]> granicus.if.org Git - vim/commitdiff
patch 8.2.0433: INT signal not properly tested v8.2.0433
authorBram Moolenaar <Bram@vim.org>
Mon, 23 Mar 2020 19:54:32 +0000 (20:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 23 Mar 2020 19:54:32 +0000 (20:54 +0100)
Problem:    INT signal not properly tested.
Solution:   Add a test.  Also clean up some unnecessary lines. (Dominique
            Pelle, closes #5828)

src/testdir/test_display.vim
src/testdir/test_ex_mode.vim
src/testdir/test_excmd.vim
src/testdir/test_messages.vim
src/testdir/test_signals.vim
src/version.c

index 199a25f1f511e140729c7952a8dbae45df52fcdf..f439bfe27237f9e0321414c826f5b71c9e1df20a 100644 (file)
@@ -192,8 +192,6 @@ func Test_edit_long_file_name()
 
   call VerifyScreenDump(buf, 'Test_long_file_name_1', {})
 
-  call term_sendkeys(buf, ":q\<cr>")
-
   " clean up
   call StopVimInTerminal(buf)
   call delete(longName)
index e50e6a57ffd188dcce3b4879daa47ed6705c0662..a72486b3728cc3b17e7ed82dadcff6210b69eb63 100644 (file)
@@ -92,7 +92,6 @@ func Test_Ex_substitute()
   call term_sendkeys(buf, ":vi\<CR>")
   call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
 
-  call term_sendkeys(buf, ":q!\n")
   call StopVimInTerminal(buf)
 endfunc
 
index 5dbb701b19dcf237a20d4c0baf8db2f8da3837e4..27fdd8835b53bba829e136b6d72e66b7865488d2 100644 (file)
@@ -255,7 +255,6 @@ func Test_confirm_cmd()
   call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
         \ term_getline(buf, 20))}, 1000)
   call term_sendkeys(buf, "N")
-  call term_sendkeys(buf, ":quit\n")
   call StopVimInTerminal(buf)
 
   call delete('foo')
index 2f8e2faf9017c8f6f0daaef67b2a535666eee600..23e7735cb085740f839d7a0e2da6b5a2616b2435 100644 (file)
@@ -265,7 +265,6 @@ func Test_message_more()
   call term_sendkeys(buf, 'q')
   call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))})
 
-  call term_sendkeys(buf, ":q!\n")
   call StopVimInTerminal(buf)
 endfunc
 
@@ -295,7 +294,6 @@ func Test_ask_yesno()
   call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))})
   call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))})
 
-  call term_sendkeys(buf, ":q!\n")
   call StopVimInTerminal(buf)
 endfunc
 
index cc1c3fb502e7373d9d2f7500c357408701044e66..7a2be899f6b2c0bf8a6981c829d6bc01ca8368f4 100644 (file)
@@ -1,6 +1,8 @@
 " Test signal handling.
 
 source check.vim
+source term_util.vim
+
 CheckUnix
 
 source shared.vim
@@ -50,7 +52,7 @@ endfunc
 " Test signal PWR, which should update the swap file.
 func Test_signal_PWR()
   if !HasSignal('PWR')
-    return
+    throw 'Skipped: PWR signal not supported'
   endif
 
   " Set a very large 'updatetime' and 'updatecount', so that we can be sure
@@ -75,3 +77,32 @@ func Test_signal_PWR()
   bwipe!
   set updatetime& updatecount&
 endfunc
+
+" Test signal INT. Handler sets got_int. It should be like typing CTRL-C.
+func Test_signal_INT()
+  if !HasSignal('INT')
+    throw 'Skipped: INT signal not supported'
+  endif
+
+  " Skip the rest of the test when running with valgrind as signal INT is not
+  " received somehow by Vim when running with valgrind.
+  let cmd = GetVimCommand()
+  if cmd =~ 'valgrind'
+    throw 'Skipped: cannot test signal INT with valgrind'
+  endif
+
+  if !CanRunVimInTerminal()
+    throw 'Skipped: cannot run vim in terminal'
+  endif
+  let buf = RunVimInTerminal('', {'rows': 6})
+  let pid_vim = term_getjob(buf)->job_info().process
+
+  " Check that an endless loop in Vim is interrupted by signal INT.
+  call term_sendkeys(buf, ":while 1 | endwhile\n")
+  call WaitForAssert({-> assert_equal(':while 1 | endwhile', term_getline(buf, 6))})
+  exe 'silent !kill -s INT ' .. pid_vim
+  call term_sendkeys(buf, ":call setline(1, 'INTERUPTED')\n")
+  call WaitForAssert({-> assert_equal('INTERUPTED', term_getline(buf, 1))})
+
+  call StopVimInTerminal(buf)
+endfunc
index 236e6f73f099eabb30c02120af4b01412044a2ff..b8552ed920f2faf5b1b4348f05381d997c1fa464 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    433,
 /**/
     432,
 /**/