diff --git a/nrepl-client.el b/nrepl-client.el index 232bff286..23dbbf6a2 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -260,9 +260,9 @@ Discards it if it can be determined that the port is not active." (when (file-exists-p file) (let ((port-string (with-temp-buffer (insert-file-contents file) - (s-trim-right (buffer-string))))) + (string-trim-right (buffer-string))))) (if (eq system-type 'windows-nt) - port-string + port-string (when (not (equal "" (shell-command-to-string (concat "lsof -i:" port-string)))) port-string))))) diff --git a/test/cider-tests.el b/test/cider-tests.el index 80c70ff85..d90851493 100644 --- a/test/cider-tests.el +++ b/test/cider-tests.el @@ -699,6 +699,18 @@ ;; kill server (delete-process (get-buffer-process client-buffer))))))) +(describe "cider-locate-running-nrepl-ports" + (it "Works" + (spy-on 'file-exists-p :and-return-value t) + (spy-on 'cider--running-lein-nrepl-paths :and-return-value '(("lein" "1234"))) + (spy-on 'cider--running-local-nrepl-paths :and-return-value '(("local" "2345"))) + (spy-on 'cider--running-non-lein-nrepl-paths :and-return-value '(("non-lein" "3456"))) + (spy-on 'cider--path->path-port-pairs :and-return-value '(("from-dir" "4567"))) + (spy-on 'directory-file-name :and-call-fake #'identity) + (spy-on 'file-name-nondirectory :and-call-fake #'identity) + (expect (cider-locate-running-nrepl-ports "from-dir") + :to-equal 123))) + (provide 'cider-tests) ;;; cider-tests.el ends here