Perfect -- I can use lein check interactively, and this in my unit tests. It's a shame *warn-on-reflection* doesn't take a function, which would be the general solution.
Phil Tassilo Horn <t...@gnu.org> writes: > phillip.l...@newcastle.ac.uk (Phillip Lord) writes: > >> I know about *warn-on-reflection* but is there anyway that I can get >> an error-on-reflection instead? > > I don't think so. > >> I've been type hinting my application (50% done and yes it goes faster >> now), and it's a bit painful. What I would really want is to have a >> unit test which fails if reflection is used. >> >> So far, my best idea is catching standard-out and parsing it for >> reflection warnings. Not ideal. > > clojure/test/clojure/test_helper.clj already contains some helper macros > for doing that, e.g., `should-not-reflect`: > > https://github.com/clojure/clojure/blob/0b73494c3c855e54b1da591eeb687f24f608f346/test/clojure/test_helper.clj#L126 > > One problem is, though, that you not only get reflection warnings for > your own code but also for code in dependencies. So you need to tweak > that macro with another regex that matches only reflection warnings in > your own files. But then you should be able to do something like this: > > > (ns myproject.test > :require [clojure.test :as test]) > > (defmacro should-not-reflect ...) > > (test/deftest no-reflection-at-all > (should-not-reflect > (do > (require 'myproject.ns1 :reload) > (require 'myproject.ns2 :reload) > ...))) > > > HTH, > Tassilo > > -- Phillip Lord, Phone: +44 (0) 191 222 7827 Lecturer in Bioinformatics, Email: phillip.l...@newcastle.ac.uk School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord Room 914 Claremont Tower, skype: russet_apples Newcastle University, twitter: phillord NE1 7RU -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.