Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scan-dirs to no longer throw #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare dotnet
uses: xt0rted/[email protected]

- name: Prepare Clojure CLR
run: |
dotnet tool install --global Clojure.Main --version 1.12.0-alpha10
dotnet tool install --global Clojure.Cljr --version 0.1.0-alpha5

- name: Run cljr tests
run: cljr -X:test
10 changes: 6 additions & 4 deletions src/main/clojure/clojure/tools/namespace/dir.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
(mapcat #(find/find-sources-in-dir % platform))
)) ;;; ditto: (map #(.getCanonicalFile ^File %))

(defn- modified-since-tracked? [tracker file]
(if-let [time (::time tracker)]
(DateTime/op_LessThan time (.LastWriteTimeUtc ^FileSystemInfo file))
true))

(defn- modified-files [tracker files]
(filter #(DateTime/op_LessThan ^DateTime (::time tracker 0) (.LastWriteTimeUTC ^FileSystemInfo %)) files)) ;;; (.lastModified ^File %)
(filter (partial modified-since-tracked? tracker) files)) ;;; (.lastModified ^File %)

(defn- deleted-files [tracker files]
(set/difference (::files tracker #{}) (set files)))
Expand Down Expand Up @@ -129,6 +134,3 @@
(instance? DirectoryInfo x) x
(string? x) (DirectoryInfo. ^String x)
:default (DirectoryInfo. (str x))))



13 changes: 12 additions & 1 deletion src/test/clojure/clojure/tools/namespace/dir_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
[clojure.tools.namespace.dir :as dir])
#_(:import
(java.io File)))

(defmacro is-not-thrown? [& body]
`(try
~@body
(is true "No exception thrown")
(catch Exception e#
(is false (str "Expected no exception, but got: " (.GetType e#) ": " (.-Message e#))))))

(deftest scan-dirs-does-not-throw
(is-not-thrown? (dir/scan-dirs {})))

;;; I don't know what the equivalent test would be for .Net.
#_(defn- make-symbolic-link
"Reflectively calls java.nio.file.Files/createSymbolicLink on two
Expand Down Expand Up @@ -35,4 +46,4 @@
link (File. other-dir "link")]
(make-symbolic-link link dir)
(is (= (::dir/files (dir/scan-dirs {} [dir]))
(::dir/files (dir/scan-dirs {} [link])))))))
(::dir/files (dir/scan-dirs {} [link])))))))