From 0eb3b3c9024d528c533d3d313ef17f6dd9bd5cab Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 28 Oct 2011 23:11:30 -0500 Subject: [PATCH] initial commit --- .gitignore | 6 ++++++ README.md | 31 +++++++++++++++++++++++++++++++ project.clj | 4 ++++ src/leiningen/expectations.clj | 30 ++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 project.clj create mode 100644 src/leiningen/expectations.clj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..488c16c --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +pom.xml +*jar +/lib/ +/classes/ +.lein-failures +.lein-deps-sum diff --git a/README.md b/README.md new file mode 100644 index 0000000..8da9915 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# lein-expectations + +A leiningen plugin to make running tests written using [expectations](https://github.com/jaycfields/expectations) library. + +## Usage + +In your project.clj: + + :dev-dependencies [[lein-expectations "0.0.1"]] + +or install as a plugin: + + $ lein plugin install lein-expectations "0.0.1" + +To run all your tests: + + $ lein expectations + +To run specific test namespaces: + + $ lein expectations my.test.namespace1 my.test.namespace2 + +To run test namespaces by regex: + + $ lein expectations my.tests.foo.* my.tests.bar.* + +## License + +Copyright (C) 2011 FIXME + +Distributed under the Eclipse Public License, the same as Clojure. diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..5eb6649 --- /dev/null +++ b/project.clj @@ -0,0 +1,4 @@ +(defproject lein-expectations "1.0.0-SNAPSHOT" + :description "FIXME: write description" + :dependencies [[org.clojure/clojure "1.2.1"]] + :eval-in-leiningen true) \ No newline at end of file diff --git a/src/leiningen/expectations.clj b/src/leiningen/expectations.clj new file mode 100644 index 0000000..5c27f13 --- /dev/null +++ b/src/leiningen/expectations.clj @@ -0,0 +1,30 @@ +(ns leiningen.expectations + (:use [leiningen.compile :only [eval-in-project]] + [leiningen.util.ns :only [namespaces-in-dir]])) + +(defn matching-ns? + [to-match] + (fn [ns] + (if (empty? to-match) + ns + (->> (for [m to-match + :let [m (re-pattern m)]] + (re-matches m (name ns))) + (some identity))))) + +(defn expectations + "Executes expectation tests in your project. + By default all test namespaces will be run, or you can specify + which namespaces to run using regex syntax to filter." + [project & args] + (let [ns (->> (namespaces-in-dir (:test-path project)) + (filter (matching-ns? args)))] + (eval-in-project + project + `(do + (doseq [n# '~ns] + (require n# :reload))) + nil + nil + '(require ['expectations])))) +