Skip to content

Commit edfe7f2

Browse files
committed
[wip] cleanup cider--enriched-cmd-p tests
1 parent f656504 commit edfe7f2

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

test/cider-tests.el

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,36 @@
106106
:and-return-value '())
107107
(expect (cider-project-type) :to-equal cider-jack-in-default))))
108108

109-
;; `cider--enriched-cmd-p', test different path + script-name combinations
110-
(let* ((paths `("/simple/path/"
111-
,(shell-quote-argument "/tmp/path/ with spaces/")
112-
,(shell-quote-argument "/ssh:!slightly@cra --zy!path #enrich me/")))
113-
(simple-names (map-values cider--enrich-classpath-script-names))
114-
(tmp-names (mapcar (lambda (s) (cider--make-temp-name s)) simple-names))
115-
(names (seq-concatenate 'list simple-names tmp-names ))
116-
(tests
117-
(lambda (script)
118-
(describe (format "cider--enriched-cmd-p with %s" script)
119-
(it "Returns the script path when cmd contains an enrich-classpath script."
120-
(expect (cider--enriched-cmd-p (concat "bash " script " /usr/bin/lein"))
121-
:to-equal script)
122-
(expect (cider--enriched-cmd-p (concat "TEST=1 bash " script " /usr/bin/env lein"))
123-
:to-equal script))
124-
;; FIXME pretty useless to do this multiple times?
125-
(it "Returns nil when the cmd does not contain an enrich-classpath script."
126-
(expect (cider--enriched-cmd-p "/usr/bin/lein")
127-
:to-equal nil)
128-
(expect (cider--enriched-cmd-p "bash /usr/bin/lein")
129-
:to-equal nil))
130-
(it "Handles a fully constructed jack-in-cmd."
131-
;; TODO generate this
132-
(let ((cmd (concat "bash " script " /usr/local/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"1.0.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.43.0\"\] -- update-in :plugins conj \[mx.cider/lein-enrich-classpath\ \"1.18.2\"\] -- update-in :middleware conj cider.enrich-classpath.plugin-v2/middleware -- repl :headless :host localhost")))
133-
(expect (cider--enriched-cmd-p cmd)
134-
:to-equal script)))))))
135-
(cl-loop for path in paths do
136-
(cl-loop for name in names do
137-
(funcall tests (concat path name)))))
109+
(describe "cider--enriched-cmd-p"
110+
(describe "when cmd does not contain the path to an enrich-classpath script"
111+
(it "returns nil"
112+
(expect (cider--enriched-cmd-p "/usr/bin/lein")
113+
:to-equal nil)
114+
(expect (cider--enriched-cmd-p "bash /usr/bin/lein")
115+
:to-equal nil)))
116+
(describe "for different path + script-name combinations"
117+
:var* ((paths `("/simple/path/"
118+
,(shell-quote-argument "/tmp/path/ with spaces/")
119+
,(shell-quote-argument "/ssh:!slightly@cra --zy!path #enrich me/")))
120+
(simple-names (map-values cider--enrich-classpath-script-names))
121+
(tmp-names (mapcar (lambda (s) (cider--make-temp-name s)) simple-names))
122+
(all-names (seq-concatenate 'list simple-names tmp-names)))
123+
(cl-loop
124+
for path in paths do
125+
(cl-loop
126+
for name in all-names do
127+
(describe (format "cider--enriched-cmd-p with script: %s" (concat path name))
128+
:var ((script (concat path name)))
129+
(it "returns the script path in basic cases "
130+
(expect (cider--enriched-cmd-p (concat "bash " script " /usr/bin/lein"))
131+
:to-equal script)
132+
(expect (cider--enriched-cmd-p (concat "TEST=1 bash " script " /usr/bin/env lein"))
133+
:to-equal script))
134+
(it "handles a fully constructed jack-in-cmd."
135+
;; TODO is it worth generating this?
136+
(let ((cmd (concat "bash " script " /usr/local/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"1.0.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.43.0\"\] -- update-in :plugins conj \[mx.cider/lein-enrich-classpath\ \"1.18.2\"\] -- update-in :middleware conj cider.enrich-classpath.plugin-v2/middleware -- repl :headless :host localhost")))
137+
(expect (cider--enriched-cmd-p cmd)
138+
:to-equal script))))))))
138139

139140
;;; cider-jack-in tests
140141
(describe "cider--gradle-dependency-notation"

0 commit comments

Comments
 (0)