mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-04 15:41:37 -05:00
Test SSH related components
This commit is contained in:
parent
82f8fe691e
commit
fb8cf1b486
3 changed files with 62 additions and 9 deletions
14
.travis.yml
14
.travis.yml
|
@ -2,6 +2,10 @@
|
|||
sudo: required
|
||||
dist: trusty
|
||||
language: nix
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- openssh-server
|
||||
matrix:
|
||||
# Report build failure/success before allowed failures complete
|
||||
fast_finish: true
|
||||
|
@ -9,8 +13,8 @@ matrix:
|
|||
- env: EMACS_CI=emacs-snapshot
|
||||
env:
|
||||
- EMACS_CI=emacs-26-1
|
||||
- EMACS_CI=emacs-26-3
|
||||
- EMACS_CI=emacs-snapshot
|
||||
# - EMACS_CI=emacs-26-3
|
||||
# - EMACS_CI=emacs-snapshot
|
||||
install:
|
||||
# Install Emacs
|
||||
- bash <(curl https://raw.githubusercontent.com/purcell/nix-emacs-ci/master/travis-install)
|
||||
|
@ -37,6 +41,10 @@ before_script:
|
|||
script:
|
||||
- export PATH=$HOME/.cask/bin:$PATH
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
# Ensure ssh does not prompt for anything
|
||||
- ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
|
||||
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
||||
- ssh -o StrictHostKeyChecking=no localhost exit
|
||||
- make dev
|
||||
- make compile
|
||||
- make test
|
||||
- make test TAGS=ssh
|
||||
|
|
|
@ -771,6 +771,40 @@
|
|||
(delete-file file)))
|
||||
(should-not (memq fun kill-emacs-hook))))
|
||||
|
||||
;; TODO: Docker test
|
||||
(ert-deftest jupyter-tunnel-connection ()
|
||||
:tags '(client ssh)
|
||||
(jupyter-test-with-kernel "python" kernel
|
||||
(with-current-buffer (process-buffer (oref kernel process))
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "Connection file: \\(.+\\)\n")
|
||||
;; Ensure this is required since TRAMP will fail without it
|
||||
;; on Travis.
|
||||
(require 'files-x)
|
||||
(let* ((method (cdr (assoc "ssh" tramp-methods)))
|
||||
(conn-file (match-string 1))
|
||||
(conn-info (jupyter-read-plist conn-file))
|
||||
(ssh-conn-file (concat "/ssh:localhost:" conn-file))
|
||||
(ssh-conn-info (jupyter-tunnel-connection ssh-conn-file)))
|
||||
;; FIXME: The IP in conn-file is already 127.0.0.1
|
||||
(should (equal (plist-get ssh-conn-info :ip) "127.0.0.1"))
|
||||
(cl-loop for port in '(:hb_port
|
||||
:control_port
|
||||
:shell_port
|
||||
:iopub_port
|
||||
:stdin_port)
|
||||
do (should-not
|
||||
(equal (plist-get conn-info port)
|
||||
(plist-get ssh-conn-info port))))
|
||||
;; Can we talk to the kernel
|
||||
(let* ((manager (jupyter-kernel-process-manager
|
||||
:kernel kernel))
|
||||
(jupyter-current-client
|
||||
(jupyter-make-client manager 'jupyter-kernel-client)))
|
||||
(jupyter-start-channels jupyter-current-client)
|
||||
(should (equal "2" (jupyter-eval "1 + 1")))
|
||||
(jupyter-stop-channels jupyter-current-client))))))
|
||||
|
||||
(ert-deftest jupyter-client-channels ()
|
||||
:tags '(client channels)
|
||||
(ert-info ("Starting/stopping channels")
|
||||
|
|
|
@ -234,6 +234,17 @@ If the `current-buffer' is not a REPL, this is identical to
|
|||
(accept-process-output nil 1)
|
||||
,@body))))
|
||||
|
||||
(defmacro jupyter-test-with-kernel (kernel-name kernel &rest body)
|
||||
"Start a new kernel with name KERNEL-NAME, bind it to KERNEL, evaluate BODY.
|
||||
KERNEL will be a `jupyter-command-kernel'."
|
||||
(declare (indent 2))
|
||||
`(let ((,kernel (jupyter-command-kernel
|
||||
:spec (jupyter-guess-kernelspec ,kernel-name))))
|
||||
(jupyter-start-kernel ,kernel)
|
||||
(unwind-protect
|
||||
(progn ,@body)
|
||||
(jupyter-kill-kernel ,kernel))))
|
||||
|
||||
(defmacro jupyter-test-with-kernel-client (kernel client &rest body)
|
||||
"Start a new KERNEL client, bind it to CLIENT, evaluate BODY.
|
||||
This only starts a single global client unless the variable
|
||||
|
|
Loading…
Add table
Reference in a new issue