File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
main/clojure/clojure/tools
test/clojure/clojure/tools/deps Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 10
10
(:require
11
11
[clojure.java.io :as jio]
12
12
[clojure.set :as set]
13
+ [clojure.spec.alpha :as s]
13
14
[clojure.string :as str]
14
15
[clojure.tools.deps.util.concurrent :as concurrent]
15
16
[clojure.tools.deps.util.dir :as dir]
16
17
[clojure.tools.deps.util.io :as io]
17
18
[clojure.tools.deps.util.session :as session]
18
19
[clojure.tools.deps.extensions :as ext]
20
+ [clojure.tools.deps.specs :as specs]
19
21
[clojure.walk :as walk])
20
22
(:import
21
23
[clojure.lang EdnReader$ReaderException]
34
36
(let [path (.getAbsolutePath f)]
35
37
(ex-info (format fmt path) {:path path})))
36
38
39
+ (defn valid-deps? [m]
40
+ (s/valid? ::specs/deps-map m))
41
+
37
42
(defn- slurp-edn-map
38
43
" Read the file specified by the path-segments, slurp it, and read it as edn."
39
44
[^File f]
43
48
(if (str/starts-with? (.getMessage t) " EOF while reading" )
44
49
(throw (io-err " Error reading edn, delimiter unmatched (%s)" f))
45
50
(throw (io-err (str " Error reading edn. " (.getMessage t) " (%s)" ) f)))))]
46
- (if (map ? val)
51
+ (if (valid-deps ? val)
47
52
val
48
- (throw (io-err " Expected edn map in: %s " f)))))
53
+ (throw (io-err " %s is not valid. " f)))))
49
54
50
55
; ; all this canonicalization is deprecated and will eventually be removed
51
56
Original file line number Diff line number Diff line change 87
87
(s/def ::paths :aliased/paths )
88
88
(s/def ::deps (s/map-of ::lib ::coord ))
89
89
(s/def ::aliases (s/map-of ::alias any?))
90
- (s/def ::deps-map (s/keys
91
- :opt-un [::paths ::deps ::aliases ]
92
- :opt [:mvn/repos :mvn/local-repo :tools/usage :deps/prep-lib ]))
90
+ (s/def ::deps-map (s/nilable ( s/ keys
91
+ :opt-un [::paths ::deps ::aliases ]
92
+ :opt [:mvn/repos :mvn/local-repo :tools/usage :deps/prep-lib ]) ))
93
93
94
94
; ; lib map
95
95
; ; a map of lib to resolved coordinate (a coord with a ::path) and dependent info
Original file line number Diff line number Diff line change 295
295
(let [b (deps/create-basis {:user nil :project adeps})]
296
296
(is (contains? (:classpath b) (.getAbsolutePath (jio/file bdir " src" ))))))))
297
297
298
+ (deftest empty-nil-deps-is-valid
299
+ (testing " file exists but is empty (nil)"
300
+ (is (deps/valid-deps? nil ))))
301
+
302
+ (deftest TDEPS-238
303
+ (testing " deps are invalid with extra nested vector in :exclusions"
304
+ (let [invalid {:deps
305
+ {'org.clojure/core.memoize
306
+ {:mvn/version " 1.0.257"
307
+ :exclusions [['org.clojure/data.priority-map]]}}}]
308
+ (is (not (deps/valid-deps? invalid))))))
309
+
298
310
(comment
299
311
(test-local-root-relative-to-project-deps )
300
312
)
You can’t perform that action at this time.
0 commit comments