Merge pull request #2273 from iperdomo/master
[#2272] Catch exceptions on malformed profiles.clj files
This commit is contained in:
commit
163887d097
4 changed files with 21 additions and 2 deletions
|
@ -46,8 +46,12 @@
|
|||
(println "Error reading"
|
||||
(.getName file)
|
||||
"from"
|
||||
(.getParent file)))
|
||||
(throw e)))))
|
||||
(.getParent file))
|
||||
(if (zero? (.length file))
|
||||
(println "File cannot be empty")
|
||||
(if (.contains (.getMessage e) "EOF while reading")
|
||||
(println "Invalid content was found")
|
||||
(println (.getMessage e)))))))))
|
||||
|
||||
(defn symlink?
|
||||
"Checks if a File is a symbolic link or points to another file."
|
||||
|
|
14
leiningen-core/test/leiningen/core/test/utils.clj
Normal file
14
leiningen-core/test/leiningen/core/test/utils.clj
Normal file
|
@ -0,0 +1,14 @@
|
|||
(ns leiningen.core.test.utils
|
||||
(:require [leiningen.core.utils :as utils]
|
||||
[clojure.test :refer [deftest testing is]]
|
||||
[clojure.java.io :as io]))
|
||||
|
||||
(def profiles "./leiningen-core/test/resources/")
|
||||
|
||||
(def sample-profile {:user {:plugins '[[lein-pprint "1.1.1"]]}})
|
||||
|
||||
(deftest read-profiles
|
||||
(testing "Empty profile file"
|
||||
(is (nil? (utils/read-file (io/file (str profiles "profiles-empty.clj"))))))
|
||||
(testing "Non-empty profile file"
|
||||
(is (= (utils/read-file (io/file (str profiles "profiles.clj"))) sample-profile))))
|
0
leiningen-core/test/resources/profiles-empty.clj
Normal file
0
leiningen-core/test/resources/profiles-empty.clj
Normal file
1
leiningen-core/test/resources/profiles.clj
Normal file
1
leiningen-core/test/resources/profiles.clj
Normal file
|
@ -0,0 +1 @@
|
|||
{:user {:plugins [[lein-pprint "1.1.1"]]}}
|
Loading…
Reference in a new issue