Skip to content

Commit 55e5d22

Browse files
authored
Fix cider-expected-ns and cider-provide-file issues on Windows tests (#3532)
- `cider-expected-ns`: can't use a fake `/a` path because it exists on the GH windows machine. - `cider-provide-file`: can't use `/tmp` as the temp directory becuase it doesn't exist. Co-authored-by: ikappaki <[email protected]>
1 parent 151b02b commit 55e5d22

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

test/cider-client-tests.el

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,30 @@
136136
(before-each
137137
(spy-on 'cider-connected-p :and-return-value t)
138138
(spy-on 'cider-classpath-entries :and-return-value
139-
'("/a" "/b" "/c" "/c/inner" "/base/clj" "/base/clj-dev"))
139+
'("/cider--a" "/cider--b" "/cider--c" "/cider--c/inner" "/cider--base/clj" "/cider--base/clj-dev"))
140140
(spy-on 'file-directory-p :and-return-value t)
141141
(spy-on 'file-in-directory-p :and-call-fake (lambda (file dir)
142142
(string-prefix-p dir file)))
143143
(spy-on 'file-relative-name :and-call-fake (lambda (file dir)
144144
(substring file (+ 1 (length dir))))))
145145

146146
(it "returns the namespace matching the given string path"
147-
(expect (cider-expected-ns "/a/foo/bar/baz_utils.clj") :to-equal
147+
(expect (cider-expected-ns "/cider--a/foo/bar/baz_utils.clj") :to-equal
148148
"foo.bar.baz-utils")
149-
(expect (cider-expected-ns "/b/foo.clj") :to-equal
149+
(expect (cider-expected-ns "/cider--b/foo.clj") :to-equal
150150
"foo")
151-
(expect (cider-expected-ns "/c/inner/foo/bar.clj") :to-equal
151+
(expect (cider-expected-ns "/cider--c/inner/foo/bar.clj") :to-equal
152152
;; NOT inner.foo.bar
153153
"foo.bar")
154-
(expect (cider-expected-ns "/c/foo/bar/baz") :to-equal
154+
(expect (cider-expected-ns "/cider--c/foo/bar/baz") :to-equal
155155
"foo.bar.baz")
156-
(expect (cider-expected-ns "/base/clj-dev/foo/bar.clj") :to-equal
156+
(expect (cider-expected-ns "/cider--base/clj-dev/foo/bar.clj") :to-equal
157157
"foo.bar")
158-
(expect (cider-expected-ns "/not/in/classpath.clj") :to-equal
159-
(clojure-expected-ns "/not/in/classpath.clj")))
158+
(expect (cider-expected-ns "/cider--not/in/classpath.clj") :to-equal
159+
(clojure-expected-ns "/cider--not/in/classpath.clj")))
160160

161161
(it "returns nil if it cannot find the namespace"
162-
(expect (cider-expected-ns "/z/abc/def") :to-equal ""))
162+
(expect (cider-expected-ns "/cider--z/abc/def") :to-equal ""))
163163

164164
(it "falls back on `clojure-expected-ns' in the absence of an active nREPL connection"
165165
(spy-on 'cider-connected-p :and-return-value nil)

test/cider-eval-tests.el

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@
3131
;; Please, for each `describe', ensure there's an `it' block, so that its execution is visible in CI.
3232

3333
(describe "cider-provide-file"
34-
(it "returns an empty string when the file is not found"
35-
(expect (cider-provide-file "abc.clj") :to-equal ""))
36-
(it "base64 encodes without newlines"
37-
(let ((cider-sideloader-path (list "/tmp"))
38-
(default-directory "/tmp")
39-
(filename (make-temp-file "abc.clj")))
40-
(with-temp-file filename
41-
(dotimes (_ 60) (insert "x")))
42-
(expect (cider-provide-file filename) :not :to-match "\n")))
43-
(it "can handle multibyte characters"
44-
(let ((cider-sideloader-path (list "/tmp"))
45-
(default-directory "/tmp")
46-
(filename (make-temp-file "abc.clj"))
47-
(coding-system-for-write 'utf-8-unix))
48-
(with-temp-file filename
49-
(insert "🍻"))
50-
(expect (cider-provide-file filename) :to-equal "8J+Nuw=="))))
34+
(let ((tmp-dir (temporary-file-directory)))
35+
(it "returns an empty string when the file is not found"
36+
(expect (cider-provide-file "abc.clj") :to-equal ""))
37+
(it "base64 encodes without newlines"
38+
(let ((cider-sideloader-path (list tmp-dir))
39+
(default-directory tmp-dir)
40+
(filename (make-temp-file "abc.clj")))
41+
(with-temp-file filename
42+
(dotimes (_ 60) (insert "x")))
43+
(expect (cider-provide-file filename) :not :to-match "\n")))
44+
(it "can handle multibyte characters"
45+
(let ((cider-sideloader-path (list tmp-dir))
46+
(default-directory tmp-dir)
47+
(filename (make-temp-file "abc.clj"))
48+
(coding-system-for-write 'utf-8-unix))
49+
(with-temp-file filename
50+
(insert "🍻"))
51+
(expect (cider-provide-file filename) :to-equal "8J+Nuw==")))))
5152

5253
(describe "cider-extract-error-info"
5354
(it "Matches Clojure compilation exceptions"

0 commit comments

Comments
 (0)