Skip to content

Commit 912c757

Browse files
committed
Update to Java commit b25992a (2017.04.25): Fix TNS-47: ensure file paths are canonical.
THis is a no-op for CLR, just updating the source files and then commenting out the new stuff.
1 parent faadb01 commit 912c757

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/clojure/tools/namespace/dir.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
(defn- find-files [dirs platform]
2323
(->> dirs
2424
(map make-dir-info) ;;; (map io/file)
25+
;;; ;;; I have no idea if this is necessary. (map #(.getCanonicalFile ^File %))
2526
(filter #(.Exists ^DirectoryInfo %)) ;;; #(.exists ^File %)
26-
(mapcat #(find/find-sources-in-dir % platform))))
27+
(mapcat #(find/find-sources-in-dir % platform))
28+
)) ;;; ditto: (map #(.getCanonicalFile ^File %))
2729

2830
(defn- modified-files [tracker files]
2931
(filter #(DateTime/op_LessThan ^DateTime (::time tracker 0) (.LastWriteTimeUTC ^FileSystemInfo %)) files)) ;;; (.lastModified ^File %)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(ns clojure.tools.namespace.dir-test
2+
(:require [clojure.test :refer [deftest is]]
3+
[clojure.tools.namespace.test-helpers :as help]
4+
[clojure.tools.namespace.dir :as dir])
5+
#_(:import
6+
(java.io File)))
7+
;;; I don't know what the equivalent test would be for .Net.
8+
#_(defn- make-symbolic-link
9+
"Reflectively calls java.nio.file.Files/createSymbolicLink on two
10+
java.io.File arguments, to avoid a compile-time dependency on
11+
java.nio.file.Files. Returns a java.io.File."
12+
[^File link ^File target]
13+
(let [path-class (Class/forName "java.nio.file.Path")
14+
attr-class (Class/forName "java.nio.file.attribute.FileAttribute")
15+
attr-array (make-array attr-class 0)
16+
attr-array-class (.getClass attr-array)
17+
to-path (.getMethod java.io.File "toPath" (into-array Class []))
18+
to-file (.getMethod path-class "toFile" (into-array Class []))
19+
create-link (.getMethod (Class/forName "java.nio.file.Files")
20+
"createSymbolicLink"
21+
(into-array Class [path-class path-class attr-array-class]))
22+
link-path (.invoke to-path link (object-array 0))
23+
target-path (.invoke to-path target (object-array 0))
24+
link (.invoke create-link path-class (object-array [link-path target-path attr-array]))]
25+
(.invoke to-file link (object-array 0))))
26+
27+
;; Only run this test on Java 1.7+, where java.nio.file.Files is available.
28+
#_(when (Class/forName "java.nio.file.Files")
29+
(deftest t-scan-by-canonical-path
30+
(let [dir (help/create-temp-dir "t-scan-by-canonical-path")
31+
main-clj (help/create-source dir 'example.main :clj '[example.one])
32+
one-cljc (help/create-source dir 'example.one :clj)
33+
other-dir (help/create-temp-dir "t-scan-by-canonical-path-other")
34+
link (File. other-dir "link")]
35+
(make-symbolic-link link dir)
36+
(is (= (::dir/files (dir/scan-dirs {} [dir]))
37+
(::dir/files (dir/scan-dirs {} [link])))))))

test/clojure/tools/namespace/track_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(let [y (add (tracker) '{ a #{b} b #{c d}})
1919
w (add y '{a #{c} b #{e} d #{f g}})]
2020
(is (equal-dep-map? y '(b a) '(a b) '{b #{c d}, a #{b}} '{d #{b}, c #{b}, b #{a}})) ;;; ordering diff on unload: '(b a)
21-
(is (equal-dep-map? w '(a d b) '(a b d) '{d #{f g}, b #{e}, a #{c}} '{g #{d}, f #{d}, e #{b}, d #{b}, c #{b a}, b #{a}}))))
21+
(is (equal-dep-map? w '(a b d) '(a b d) '{d #{f g}, b #{e}, a #{c}} '{g #{d}, f #{d}, e #{b}, d #{b}, c #{b a}, b #{a}})))) ;; ordering diff on unload: '(a d b))
2222

2323
(deftest t-remove
2424
(let [y (add (tracker) '{ a #{b} b #{c d}})

0 commit comments

Comments
 (0)