]> granicus.if.org Git - vim/commitdiff
patch 8.1.1047: WINCH signal is not tested v8.1.1047
authorBram Moolenaar <Bram@vim.org>
Sun, 24 Mar 2019 13:58:31 +0000 (14:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 24 Mar 2019 13:58:31 +0000 (14:58 +0100)
Problem:    WINCH signal is not tested.
Solution:   Add a test. (Dominique Pelle, closes #4158)

src/testdir/Make_all.mak
src/testdir/test_signals.vim [new file with mode: 0644]
src/version.c

index c12a59ea9d419c946e0b760703211281f7d2a1d5..8581700adc0fd88f1dc6b2542ab7b04c6f64b8da 100644 (file)
@@ -224,6 +224,7 @@ NEW_TESTS = \
        test_searchpos \
        test_set \
        test_sha256 \
+       test_signals \
        test_signs \
        test_smartindent \
        test_sort \
@@ -385,6 +386,7 @@ NEW_TESTS_RES = \
        test_scrollbind.res \
        test_search.res \
        test_shortpathname.res \
+       test_signals.res \
        test_signs.res \
        test_smartindent.res \
        test_source.res \
diff --git a/src/testdir/test_signals.vim b/src/testdir/test_signals.vim
new file mode 100644 (file)
index 0000000..3fea76b
--- /dev/null
@@ -0,0 +1,44 @@
+" Test signal handling.
+
+if !has('unix')
+  finish
+endif
+
+source shared.vim
+
+" Test signal WINCH (window resize signal)
+func Test_signal_WINCH()
+  let signals = system('kill -l')
+  if signals !~ '\<WINCH\>'
+    " signal WINCH is not available, skip the test.
+    return
+  endif
+
+  " We do not actually want to change the size of the terminal.
+  let old_WS = ''
+  if exists('&t_WS')
+    let old_WS = &t_WS
+    let &t_WS = ''
+  endif
+
+  let old_lines = &lines
+  let old_columns = &columns
+  let new_lines = &lines - 2
+  let new_columns = &columns - 2
+
+  exe 'set lines=' . new_lines
+  exe 'set columns=' . new_columns
+  call assert_equal(new_lines, &lines)
+  call assert_equal(new_columns, &columns)
+
+  " Send signal and wait for signal to be processed.
+  " 'lines' and 'columns' should have been restored
+  " after handing signal WINCH.
+  exe 'silent !kill -s WINCH ' . getpid()
+  call WaitForAssert({-> assert_equal(old_lines, &lines)})
+  call assert_equal(old_columns, &columns)
+
+  if old_WS != ''
+    let &t_WS = old_WS
+  endif
+endfunc
index 3a195e5c49d83650d2547b27a72c1e37adf61d54..cb044bc7238051f97a615ac4c946684bb9c365a0 100644 (file)
@@ -775,6 +775,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1047,
 /**/
     1046,
 /**/