Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First basic version of lein generative

  • Loading branch information...
commit 9c68483aa91709c7812899f2a07f00d314d5b3a0 0 parents
@roman roman authored
8 .gitignore
@@ -0,0 +1,8 @@
+/pom.xml
+*jar
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
13 README
@@ -0,0 +1,13 @@
+# lein-generative
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2011 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
5 project.clj
@@ -0,0 +1,5 @@
+(defproject lein-generative "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dev-dependencies [[org.clojure/test.generative "0.1.3"]]
+ :eval-in-leiningen true)
+
44 src/leiningen/generative.clj
@@ -0,0 +1,44 @@
+(ns leiningen.generative
+ (:refer-clojure :exclude [test])
+ (:require leiningen.core)
+ (:use [leiningen.compile :only [eval-in-project]]
+ [leiningen.classpath :only [classpath]]))
+
+(defn- run-generative-tests [project]
+ `(do
+ (println "Testing on" gen/*cores* "cores for" gen/*msec* "msec.")
+ (let [futures# (gen/test-dirs ~(:generative-path project))]
+ (doseq [f# futures#]
+ (try
+ @f#
+ (catch Throwable t#)
+ ;(.printStackTrace t#)
+ ;(System/exit -1))
+
+ (finally
+ (when-not ~leiningen.core/*interactive?*
+ (shutdown-agents))))))))
+
+(defn- set-generative-path-to-project [project]
+ (let [generative-path (str (:root project)
+ java.io.File/separatorChar
+ "generative")]
+ (merge {:generative-path generative-path} project)))
+
+(defn- add-generative-path-to-classpath [project]
+ (update-in project
+ [:extra-classpath-dirs]
+ #(conj % (:generative-path project))))
+
+(defn generative
+ "Run test.generative tests"
+ [project & _]
+ (let [new-project (-> project
+ set-generative-path-to-project
+ add-generative-path-to-classpath)]
+ (eval-in-project
+ new-project
+ (run-generative-tests new-project)
+ nil
+ nil
+ '(require '[clojure.test.generative :as gen]))))
Please sign in to comment.
Something went wrong with that request. Please try again.