Skip to content

Commit

Permalink
describe "cider-locate-running-nrepl-ports"
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Aug 14, 2023
1 parent 3d052a8 commit 72ceec2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nrepl-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Expand Down
12 changes: 12 additions & 0 deletions test/cider-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 72ceec2

Please sign in to comment.