eftest icon indicating copy to clipboard operation
eftest copied to clipboard

Support for selectors in the repl?

Open glenjamin opened this issue 6 years ago • 4 comments

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!)

glenjamin avatar Feb 22 '19 11:02 glenjamin

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.

weavejester avatar Feb 22 '19 11:02 weavejester

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 avatar Feb 22 '19 11:02 glenjamin

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)

glenjamin avatar Feb 22 '19 12:02 glenjamin

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.

weavejester avatar Feb 22 '19 12:02 weavejester