Test plugin installation and create plugins dir where necessary.
This commit is contained in:
parent
c749a497aa
commit
08522f89e5
3 changed files with 22 additions and 6 deletions
|
@ -7,7 +7,7 @@
|
||||||
[leiningen.jar :only (local-repo-path
|
[leiningen.jar :only (local-repo-path
|
||||||
extract-jar
|
extract-jar
|
||||||
get-default-uberjar-name)]
|
get-default-uberjar-name)]
|
||||||
[leiningen.util.file :only (tmp-dir)]
|
[leiningen.util.file :only (tmp-dir delete-file-recursively)]
|
||||||
[clojure.java.io :only (file)])
|
[clojure.java.io :only (file)])
|
||||||
(:require [leiningen.install]
|
(:require [leiningen.install]
|
||||||
[leiningen.help])
|
[leiningen.help])
|
||||||
|
@ -31,6 +31,7 @@ Syntax: lein plugin install [GROUP/]ARTIFACT-ID VERSION
|
||||||
dependencies."
|
dependencies."
|
||||||
[project-name version]
|
[project-name version]
|
||||||
(leiningen.install/install project-name version)
|
(leiningen.install/install project-name version)
|
||||||
|
(.mkdirs plugins-path)
|
||||||
(let [[name group] (extract-name-and-group project-name)
|
(let [[name group] (extract-name-and-group project-name)
|
||||||
temp-project (format "%s/lein-%s" tmp-dir (java.util.UUID/randomUUID))
|
temp-project (format "%s/lein-%s" tmp-dir (java.util.UUID/randomUUID))
|
||||||
jarfile (-> (local-repo-path name (or group name) version)
|
jarfile (-> (local-repo-path name (or group name) version)
|
||||||
|
@ -46,6 +47,7 @@ Syntax: lein plugin install [GROUP/]ARTIFACT-ID VERSION
|
||||||
(filter #(.endsWith (.getName %) ".jar"))
|
(filter #(.endsWith (.getName %) ".jar"))
|
||||||
(cons (file jarfile)))]
|
(cons (file jarfile)))]
|
||||||
(write-components deps out)))
|
(write-components deps out)))
|
||||||
|
(delete-file-recursively temp-project)
|
||||||
(println "Created" standalone-filename)))
|
(println "Created" standalone-filename)))
|
||||||
|
|
||||||
(defn uninstall
|
(defn uninstall
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
(def tmp-dir (System/getProperty "java.io.tmpdir"))
|
(def tmp-dir (System/getProperty "java.io.tmpdir"))
|
||||||
|
|
||||||
|
(defn unique-lein-tmp-dir []
|
||||||
|
(file tmp-dir (str "lein-" (java.util.UUID/randomUUID))))
|
||||||
|
|
||||||
;; grumble, grumble; why didn't this make it into clojure.java.io?
|
;; grumble, grumble; why didn't this make it into clojure.java.io?
|
||||||
(defn delete-file-recursively
|
(defn delete-file-recursively
|
||||||
"Delete file f. If it's a directory, recursively delete all its contents.
|
"Delete file f. If it's a directory, recursively delete all its contents.
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
(ns test-plugin
|
(ns test-plugin
|
||||||
(:use [leiningen.plugin] :reload)
|
(:use [leiningen.plugin]
|
||||||
|
[leiningen.util.file :only (unique-lein-tmp-dir
|
||||||
|
delete-file-recursively)]
|
||||||
|
[leiningen.compile :only (platform-nullsink)]
|
||||||
|
[leiningen.core :only (read-project defproject)]
|
||||||
|
[clojure.java.io :only (file)])
|
||||||
(:use [clojure.test]))
|
(:use [clojure.test]))
|
||||||
|
|
||||||
(deftest test-plugin-standalone-filename
|
(deftest test-plugin-standalone-filename
|
||||||
|
@ -28,8 +33,14 @@ uninstall Delete the plugin jarfile
|
||||||
Syntax: lein plugin uninstall [GROUP/]ARTIFACT-ID VERSION\n"
|
Syntax: lein plugin uninstall [GROUP/]ARTIFACT-ID VERSION\n"
|
||||||
(with-out-str (plugin "help")))))
|
(with-out-str (plugin "help")))))
|
||||||
|
|
||||||
|
(defonce test-project (read-project "test_projects/sample/project.clj"))
|
||||||
|
|
||||||
|
(deftest test-install
|
||||||
|
(with-out-str
|
||||||
|
(leiningen.install/install test-project)
|
||||||
|
(binding [plugins-path (unique-lein-tmp-dir)
|
||||||
|
leiningen.install/install (constantly nil)]
|
||||||
|
(install "nomnomnom" "0.5.0-SNAPSHOT")
|
||||||
|
(is (.exists (file plugins-path "nomnomnom-0.5.0-SNAPSHOT.jar")))
|
||||||
|
(delete-file-recursively plugins-path))))
|
||||||
|
|
||||||
;; TODO: figure out a clever way to actually test instaling
|
|
||||||
;; (deftest test-install
|
|
||||||
;; (install "lein-plugin" "0.1.0")
|
|
||||||
;; )
|
|
||||||
|
|
Loading…
Reference in a new issue