Merge pull request #2273 from iperdomo/master

[#2272] Catch exceptions on malformed profiles.clj files
This commit is contained in:
Phil Hagelberg 2017-05-11 10:17:07 -07:00 committed by GitHub
commit 163887d097
4 changed files with 21 additions and 2 deletions

View file

@ -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."

View 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))))

View file

@ -0,0 +1 @@
{:user {:plugins [[lein-pprint "1.1.1"]]}}