Skip to content

Commit

Permalink
Add some basic tests for upwards-file-search
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Apr 3, 2022
1 parent c9f8e05 commit 7346953
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .fs.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is here to test some filesystem related things.
1 change: 1 addition & 0 deletions test/fnl/conjure/.fs.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is _also_ here to test some filesystem related things.
29 changes: 29 additions & 0 deletions test/fnl/conjure/fs-test.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,32 @@
(t.= nil (fs.file-path->module-name ex-no-file))

(tset package.loaded ex-mod nil))

(deftest upwards-file-search
;; No match
(t.= nil (fs.upwards-file-search [] (nvim.fn.getcwd)))
(t.= nil (fs.upwards-file-search ["thisbetternotexist"] (nvim.fn.getcwd)))

;; Match in the cwd
(t.= "README.adoc"
(fs.upwards-file-search
["README.adoc"]
(nvim.fn.getcwd)))

;; Match by walking upwards
(t.= "README.adoc"
(fs.upwards-file-search
["README.adoc"]
(.. (nvim.fn.getcwd) "/test/fnl/conjure/client/clojure/nrepl")))

;; Matching below first, return early
(t.= "test/fnl/conjure/.fs.test"
(fs.upwards-file-search
["README.adoc" ".fs.test"]
(.. (nvim.fn.getcwd) "/test/fnl/conjure/client/clojure/nrepl")))

;; Matching at same level first, return early
(t.= "test/fnl/conjure/.fs.test"
(fs.upwards-file-search
["README.adoc" ".fs.test"]
(.. (nvim.fn.getcwd) "/test/fnl/conjure"))))

0 comments on commit 7346953

Please sign in to comment.