[neovim] 03/11: test: Handle SIGHUP in tty-test fixture.

James McCoy jamessan at debian.org
Sat Dec 24 21:14:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch debian/sid
in repository neovim.

commit c9404803316b2b280463bb9b5f3bd9204620dd54
Author: Justin M. Keyes <justinkz at gmail.com>
Date:   Wed Dec 7 14:01:51 2016 +0100

    test: Handle SIGHUP in tty-test fixture.
    
    Closes #5727
---
 test/functional/core/job_spec.lua   |  5 ++---
 test/functional/fixtures/tty-test.c | 24 +++++++++++++++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 58594db..9d24ba6 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -481,10 +481,9 @@ describe('jobs', function()
       eq('rows: 40, cols: 10', next_chunk())
     end)
 
-    it('calling jobclose()', function()
-      -- this should send SIGHUP to the process
+    it('jobclose() sends SIGHUP', function()
       nvim('command', 'call jobclose(j)')
-      eq({'notification', 'exit', {0, 1}}, next_msg())
+      eq({'notification', 'exit', {0, 42}}, next_msg())
     end)
   end)
 end)
diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c
index ca905ce..778e7f3 100644
--- a/test/functional/fixtures/tty-test.c
+++ b/test/functional/fixtures/tty-test.c
@@ -32,11 +32,21 @@ static void walk_cb(uv_handle_t *handle, void *arg) {
 }
 
 #ifndef WIN32
-static void sigwinch_handler(int signum)
+static void sig_handler(int signum)
 {
-  int width, height;
-  uv_tty_get_winsize(&tty, &width, &height);
-  fprintf(stderr, "rows: %d, cols: %d\n", height, width);
+  switch(signum) {
+  case SIGWINCH: {
+    int width, height;
+    uv_tty_get_winsize(&tty, &width, &height);
+    fprintf(stderr, "rows: %d, cols: %d\n", height, width);
+    return;
+  }
+  case SIGHUP:
+    exit(42);  // arbitrary exit code to test against
+    return;
+  default:
+    return;
+  }
 }
 #endif
 
@@ -141,7 +151,8 @@ int main(int argc, char **argv)
   struct sigaction sa;
   sigemptyset(&sa.sa_mask);
   sa.sa_flags = 0;
-  sa.sa_handler = sigwinch_handler;
+  sa.sa_handler = sig_handler;
+  sigaction(SIGHUP, &sa, NULL);
   sigaction(SIGWINCH, &sa, NULL);
   // uv_signal_t sigwinch_watcher;
   // uv_signal_init(uv_default_loop(), &sigwinch_watcher);
@@ -150,5 +161,8 @@ int main(int argc, char **argv)
 #endif
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
 
+  // XXX: Without this the SIGHUP handler is skipped on some systems.
+  sleep(100);
+
   return 0;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vim/neovim.git



More information about the pkg-vim-maintainers mailing list