Skip to content

Commit

Permalink
[Fix #2659] Handle #shadow/env tag when getting shadow-cljs builds (#…
Browse files Browse the repository at this point in the history
…2668)

Since builds are unlikely to be set from env variables just pass the
`#shadow/env` tag values to `identity`, preventing things from crashing.
  • Loading branch information
rpkarlsson authored and bbatsov committed Jul 5, 2019
1 parent 0e1224a commit 1a194f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [#2607](https://github.com/clojure-emacs/cider/pull/2607): Use markers for specifying insertion point for `cider-eval-*-to-comment`commands. This fixes a bug where editing the buffer during a pending evaluation resulted in comments appearing in unintended locations.
* [#2308](https://github.com/clojure-emacs/cider/issues/2308): Don't rely on the classpath in `cider-library-present-p`. Now it does a `require` instead to check if some library is present or not.
* [#2541](https://github.com/clojure-emacs/cider/issues/2541): Hook properly CIDER's code completion machinery.
* [#2659](https://github.com/clojure-emacs/cider/issues/2659): Handle `#shadow/env` reader tags in `cider--shadow-get-builds`.

## 0.21.0 (2019-02-19)

Expand Down
2 changes: 1 addition & 1 deletion cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ The default options of `browser-repl' and `node-repl' are also included."
(when (file-exists-p shadow-edn)
(with-temp-buffer
(insert-file-contents shadow-edn)
(let ((hash (car (parseedn-read))))
(let ((hash (car (parseedn-read '((shadow/env . identity))))))
(cider--shadow-parse-builds hash))))))

(defun cider-shadow-select-cljs-init-form ()
Expand Down
29 changes: 29 additions & 0 deletions test/cider-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,35 @@
(expect (cider--shadow-parse-builds (parseedn-read-str "[oops]"))
:to-equal '(browser-repl node-repl))))

(defmacro with-temp-shadow-config (contents &rest body)
"Run BODY with a mocked shadow-cljs.edn project file with the CONTENTS."
`(let* ((edn-file "shadow-cljs.edn")
(temp-dir (temporary-file-directory))
(file-path (concat temp-dir edn-file)))
(with-temp-file file-path
(insert ,contents))
(spy-on 'clojure-project-dir :and-return-value temp-dir)
,@body
(delete-file file-path)))

(describe "cider--shadow-get-builds"
(it "handles EDN reader tags"
(with-temp-shadow-config
"{:builds {:app {} :release {}} :key #shadow/env \"foo\"}"
(expect (cider--shadow-get-builds)
:to-have-same-items-as '(:release :app browser-repl node-repl))))

(it "returns default options on empty / invalid input"
(with-temp-shadow-config
"{}"
(expect (cider--shadow-get-builds)
:to-have-same-items-as '(browser-repl node-repl)))

(with-temp-shadow-config
"[oops]"
(expect (cider--shadow-get-builds)
:to-have-same-items-as '(browser-repl node-repl)))))

(provide 'cider-tests)

;;; cider-tests.el ends here

0 comments on commit 1a194f9

Please sign in to comment.