Merge in better error messages for -m in lein run.
This commit is contained in:
commit
ab7f332797
2 changed files with 20 additions and 1 deletions
|
@ -6,6 +6,10 @@
|
|||
(clojure.lang Reflector)))
|
||||
|
||||
(defn- normalize-main [given]
|
||||
(when-not (or (symbol? given)
|
||||
(and (string? given) (symbol? (read-string given))))
|
||||
(main/abort (str "Option -m requires a valid namespace argument, not "
|
||||
given ".")))
|
||||
(if (namespace (symbol given))
|
||||
(symbol given)
|
||||
(symbol (name given) "-main")))
|
||||
|
@ -70,7 +74,11 @@
|
|||
|
||||
;; If we got an exception earlier and nothing else worked,
|
||||
;; rethrow that.
|
||||
(= :threw ns-flag#) (throw data#)))))
|
||||
(= :threw ns-flag#)
|
||||
(do (binding [*out* *err*]
|
||||
(println (str "Can't find '" '~given "' as .class or .clj for "
|
||||
"lein run: please check the spelling.")))
|
||||
(throw data#))))))
|
||||
|
||||
(defn- run-main
|
||||
"Loads the project namespaces as well as all its dependencies and then calls
|
||||
|
|
|
@ -22,6 +22,17 @@
|
|||
(run tricky-name-project "-m" "org.domain.tricky-name.munch" "/unreadable")
|
||||
(is (= ":munched (\"/unreadable\")" (slurp out-file))))
|
||||
|
||||
(deftest test-valid-namespace-argument
|
||||
(is (re-find #"Option -m requires a valid namespace argument, not -1\."
|
||||
(helper/abort-msg run tricky-name-project "-m" "-1"))))
|
||||
|
||||
(deftest test-nonexistant-ns-error-message
|
||||
(is (re-find #"Can't find 'nonexistant.ns' as \.class or \.clj for lein run"
|
||||
(with-out-str
|
||||
(binding [*err* *out*]
|
||||
(try (run tricky-name-project "-m" "nonexistant.ns")
|
||||
(catch Exception _)))))))
|
||||
|
||||
(deftest test-escape-args
|
||||
(run tricky-name-project "--" ":bbb")
|
||||
(is (= "nom::bbb" (slurp out-file)))
|
||||
|
|
Loading…
Reference in a new issue