Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fork to work with Leiningen 2.

  • Loading branch information...
commit fc5c047f279f4d98ab5841420c8e05e3287cee44 1 parent f54c075
Steve Losh authored
1  .gitignore
View
@@ -2,6 +2,7 @@
*jar
/lib
/classes
+/target
/native
/.lein-failures
/checkouts
10 README.markdown
View
@@ -1,4 +1,8 @@
-# lein-generative
+# lein2-generative
+
+**A fork of lein-generative to make it work with Leiningen 2.**
+
+**Also prettifies the output a bit.**
A [Leiningen](https://github.com/technomancy/leiningen) plugin used to run generative tests defined using the [test.generative](https://github.com/clojure/test.generative) Clojure contrib library.
@@ -6,9 +10,9 @@ A [Leiningen](https://github.com/technomancy/leiningen) plugin used to run gener
*This is currently only proven to work in Leiningen versions earlier than 2.0*
-Add the following to your Leiningen `project.clj` file in the `:dev-dependencies` section:
+Add the following to your Leiningen `project.clj` file in the `:plugins` section:
- [lein-generative "0.1.4.0"]
+ [sjl/lein2-generative "0.1.4.2"]
The version number of lein-generative will track the latest released version of test.generative. The end of the version number will be the specific sub-version of this plugin.
2  project.clj
View
@@ -1,4 +1,4 @@
-(defproject lein-generative "0.1.4.1-SNAPSHOT"
+(defproject sjl/lein2-generative "0.1.4.2"
:description "test.generative runner for Clojure contrib's test.generative."
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/test.generative "0.1.4"]]
45 src/leiningen/generative.clj
View
@@ -1,25 +1,46 @@
(ns leiningen.generative
(:refer-clojure :exclude [test])
- (:require leiningen.core)
- (:use [leiningen.compile :only [eval-in-project]]
+ (:use [leiningen.test :only [*exit-after-tests*]]
+ [leiningen.core.eval :only [eval-in-project]]
+ [clojure.pprint :only [pprint]]
[leiningen.classpath :only [classpath]]))
+
(defn- run-generative-tests [project]
`(do
(let [path# ~(or (:generative-path project) "test/")]
+ (letfn [(print-line# [line-contents#]
+ (println (apply str (take 80 (cycle line-contents#)))))
+ (report# [result#]
+ (if-let [err# (:error result#)]
+ (do
+ (println)
+ (print-line# "=")
+ (println "FAILURE")
+ (print-line# "=")
+ (println ":file " (str path#
+ java.io.File/separatorChar
+ (-> result# :form first meta :file)))
+ (println ":spec " (-> result# :form first meta :name))
+ (println)
+ (print ":form ")
+ (prn (:form result#))
+ (println ":error " err#)
+ (println)
+ (println ":seed " (:seed result#))
+ (println ":iteration" (:iteration result#))
+ (print-line# "="))
+ (prn result#)))]
+ (dosync (reset! gen/report-fn report#)))
(println "Testing generative tests in" path#
"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)))))))))
+ (try (doseq [f# futures#]
+ (try @f# (catch Throwable t#)))
+ (finally
+ (when ~*exit-after-tests*
+ (shutdown-agents))))))))
(defn- set-generative-path-to-project [project]
(let [generative-path (str (:root project)
@@ -41,6 +62,4 @@
(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.