weavejester / eftest

Fast and pretty Clojure test runner
424 stars 40 forks source link

Support for selectors in the repl? #64

Open glenjamin opened 5 years ago

glenjamin commented 5 years ago

I would quite like to run all tests, excluding some integration tests from the repl.

At the moment it looks like all of the selector logic is in the lein plugin. Would it be possible to move the filtering logic into the repl side, even if the selector configuration needs to stay in the plugin?

(also: thanks for making this, it's great!)

weavejester commented 5 years ago

What sort of filtering logic would be moved? Current you can insert a filter directly at the REPL:

(->> (find-tests "test") (filter whatever?) (run-tests))

I believe you can also use (filter (comp #{:tag} meta)) to filter on a particular metadata tag.

glenjamin commented 5 years ago

Oh, I hadn't realised it was that simple - I glanced at the code in https://github.com/weavejester/eftest/blob/master/lein-eftest/src/leiningen/eftest.clj#L24 and my eyes wen't fuzzy 😄

glenjamin commented 5 years ago

Ok, I ended up doing something like this, which feels a little bit wordy.

(as-> (find-tests "test") ts
 (filter (complement (comp :integration meta)) ts)
 (run-tests ts {:multithread? false}))

There are probably better ways to shuffle the arguments around, but my clojure is a bit rusty.

I'm not sure if putting this into the lib itself would be a big improvement, or where it would go if it was attempted.

(edit: I should add that at the moment I'm using this via a local profile, and not adding anything into the project for its other contributors, if we decide to all use it I could add a simple wrapper fn easily enough)

weavejester commented 5 years ago

I'm tentatively of the opinion that a function like this could be added to your development environment. Perhaps something like:

(ns user
  (:require [eftest.runner :as ef]))

(defn run-tests []
  (as-> (ef/find-tests "test") ts
   (filter (complement (comp :integration meta)) ts)
   (ef/run-tests ts {:multithread? false}))

You could also play around with a wrapper that accepts a transducer.