Added a build-failing project for flexing compilation-failing aware 'jar'; created test_projects and moved sample there too

This commit is contained in:
Alan Dipert 2010-08-23 23:03:52 -04:00
parent 3f4e557d80
commit 93535c5a17
18 changed files with 73 additions and 26 deletions

View file

@ -154,12 +154,17 @@ those given as command-line arguments."
(.mkdir (file (:compile-path project))) (.mkdir (file (:compile-path project)))
(if (seq (compilable-namespaces project)) (if (seq (compilable-namespaces project))
(if-let [namespaces (seq (stale-namespaces project))] (if-let [namespaces (seq (stale-namespaces project))]
(eval-in-project project (let [exit-status (eval-in-project project
`(doseq [namespace# '~namespaces] `(doseq [namespace# '~namespaces]
(when-not ~*silently* (when-not ~*silently*
(println "Compiling" namespace#)) (println "Compiling" namespace#))
(clojure.core/compile namespace#)) (clojure.core/compile namespace#))
nil :skip-auto-compile) nil :skip-auto-compile)]
(if (= 1 exit-status)
(do (binding [*out* *err*]
(println "Compilation failed."))
false)
true))
(when-not *silently* (when-not *silently*
(println "All namespaces already :aot compiled."))) (println "All namespaces already :aot compiled.")))
(when-not *silently* (when-not *silently*

View file

@ -154,10 +154,10 @@ well as the source .clj files. If project.clj contains a :main symbol, it will
be used as the main-class for an executable jar." be used as the main-class for an executable jar."
([project jar-name] ([project jar-name]
(binding [compile/*silently* true] (binding [compile/*silently* true]
(compile/compile project)) (when (compile/compile project)
(let [jar-path (get-jar-filename project jar-name) (let [jar-path (get-jar-filename project jar-name)
deps-fileset (deps project :skip-dev)] deps-fileset (deps project :skip-dev)]
(write-jar project jar-path (filespecs project deps-fileset)) (write-jar project jar-path (filespecs project deps-fileset))
(println "Created" jar-path) (println "Created" jar-path)
jar-path)) jar-path))))
([project] (jar project (get-default-jar-name project)))) ([project] (jar project (get-default-jar-name project))))

View file

@ -60,14 +60,19 @@
the dependency jars. Suitable for standalone distribution." the dependency jars. Suitable for standalone distribution."
([project uberjar-name] ([project uberjar-name]
(doto project (doto project
clean deps jar) clean deps)
(let [standalone-filename (get-jar-filename project uberjar-name)] (if (jar project)
(with-open [out (-> standalone-filename (let [standalone-filename (get-jar-filename project uberjar-name)]
(FileOutputStream.) (with-open [out (-> standalone-filename
(ZipOutputStream.))] (FileOutputStream.)
(let [deps (->> (.listFiles (file (:library-path project))) (ZipOutputStream.))]
(filter #(.endsWith (.getName %) ".jar")) (let [deps (->> (.listFiles (file (:library-path project)))
(cons (file (get-jar-filename project))))] (filter #(.endsWith (.getName %) ".jar"))
(write-components deps out))) (cons (file (get-jar-filename project))))]
(println "Created" standalone-filename))) (write-components deps out)))
(println "Created" standalone-filename))
(do
(binding [*out* *err*]
(println "Uberjar aborting because jar/compilation failed."))
(System/exit 1))))
([project] (uberjar project (get-default-uberjar-name project)))) ([project] (uberjar project (get-default-uberjar-name project))))

View file

@ -5,7 +5,7 @@
[clojure.contrib.set] [clojure.contrib.set]
[clojure.contrib.io :only [file delete-file-recursively]])) [clojure.contrib.io :only [file delete-file-recursively]]))
(def test-project (read-project "sample/project.clj")) (def test-project (read-project "test_projects/sample/project.clj"))
(deftest test-deps (deftest test-deps
(delete-file-recursively (file (:root test-project) "lib") true) (delete-file-recursively (file (:root test-project) "lib") true)

View file

@ -8,7 +8,7 @@
(def m2-dir (file (System/getProperty "user.home") ".m2" "repository" (def m2-dir (file (System/getProperty "user.home") ".m2" "repository"
"nomnomnom" "nomnomnom" "0.5.0-SNAPSHOT")) "nomnomnom" "nomnomnom" "0.5.0-SNAPSHOT"))
(defonce test-project (read-project "sample/project.clj")) (defonce test-project (read-project "test_projects/sample/project.clj"))
(deftest test-install (deftest test-install
(delete-file-recursively m2-dir true) (delete-file-recursively m2-dir true)

View file

@ -14,7 +14,7 @@
(select-keys manifest ["hello" "Main-Class"]))))) (select-keys manifest ["hello" "Main-Class"])))))
(def sample-project (binding [*ns* (the-ns 'leiningen.core)] (def sample-project (binding [*ns* (the-ns 'leiningen.core)]
(read-project "sample/project.clj"))) (read-project "test_projects/sample/project.clj")))
(deftest test-jar (deftest test-jar
(let [jar-file (JarFile. (jar sample-project)) (let [jar-file (JarFile. (jar sample-project))
@ -30,3 +30,14 @@
manifest (manifest-map (.getManifest jar-file))] manifest (manifest-map (.getManifest jar-file))]
(is (nil? (.getEntry jar-file "bin/nom"))) (is (nil? (.getEntry jar-file "bin/nom")))
(is (nil? (manifest "Leiningen-shell-wrapper"))))) (is (nil? (manifest "Leiningen-shell-wrapper")))))
(def sample-failing-project
(binding [*ns* (the-ns 'leiningen.core)]
(read-project "test_projects/sample_failing/project.clj")))
(deftest test-jar-fails
(println "**********************************************")
(println "***** You're about to see a stack trace. *****")
(println "***** Stay cool, it's part of the test. *****")
(println "**********************************************")
(is (not (jar sample-failing-project))))

View file

@ -5,7 +5,7 @@
(:use [clojure.test] (:use [clojure.test]
[clojure.contrib.io :only [file delete-file]])) [clojure.contrib.io :only [file delete-file]]))
(def test-project (read-project "sample/project.clj")) (def test-project (read-project "test_projects/sample/project.clj"))
(deftest test-pom (deftest test-pom
(let [pom-file (file (:root test-project) "pom.xml")] (let [pom-file (file (:root test-project) "pom.xml")]

4
test_projects/README.txt Normal file
View file

@ -0,0 +1,4 @@
These projects are used for leiningen's test suite, so don't change
any of these values without updating the relevant tests. If you
just want a basic project to work from, generate a new one with
"lein new".

View file

@ -0,0 +1,9 @@
;; This project is used for leiningen's test suite, so don't change
;; any of these values without updating the relevant tests. If you
;; just want a basic project to work from, generate a new one with
;; "lein new".
(def clj-version "1.1.0-master-SNAPSHOT")
(defproject nomnomnom "0.5.0-SNAPSHOT"
:dependencies [[~(symbol "org.clojure" "clojure") ~clj-version]])

View file

@ -0,0 +1,13 @@
(ns nom.nom.nom
(:gen-class))
This noming squirrel will cause compilation of this file to fail.
,;;:;,
;;;;;
,:;;:; ,'=.
;:;:;' .=" ,'_\
':;:;,/ ,__:=@
';;:; =./)_
`"=\_ )_"`
``'"