jcrossley3 / lein-modules

An alternative to Maven multi-module projects in Leiningen
Eclipse Public License 1.0
83 stars 16 forks source link

Allow :test-selectors inheritance #17

Closed kholodilov closed 10 years ago

kholodilov commented 10 years ago

:test-selectors configuration isn't inherited from parent to children. If it is specified as root key in parent module (as it would be specified in children modules directly), it has no effect. If it is specified inside :inherited, then build fails with some obscure error:

lein modules test

Module build order: service data-source client

Building service 0.1.0-SNAPSHOT (inherited,default)

Exception in thread "main" java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/fn, compiling:(/private/var/folders/t1/d2c10cfn4yv8n7y359q3nm380000gn/T/form-init3343548599731543118.clj:1:6835) at clojure.lang.Compiler.analyze(Compiler.java:6464) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.eval(Compiler.java:6700) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/fn at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6850) at clojure.lang.Compiler.analyze(Compiler.java:6427) ... 42 more Tests failed. Error encountered performing task 'test' with profile(s): 'inherited-crossroads-simulator,base-service,base-crossroads-simulator,system,user,provided,dev' Tests failed. Subprocess failed

jcrossley3 commented 10 years ago

Good catch, thanks! Just back from vacation, I'm able to reproduce this. Hope to have a fix soon.

jcrossley3 commented 10 years ago

This is actually a problem with Leiningen itself. See https://github.com/technomancy/leiningen/issues/878

You can easily replicate the problem with the following project.clj:

    (defproject selector "0.1.0-SNAPSHOT"
      :dependencies [[org.clojure/clojure "1.6.0"]]
      :test-selectors {:default (fn [m] true)}
      :profiles {:foo {:test-selectors {:default (fn [m] true)}}})

Run lein test and then lein with-profile +foo test to see the same obscure error.

You can work around the issue by adding :replace metadata to the :test-selectors in your parent project, e.g. https://gist.github.com/b6315e92d69c610c4aad

kholodilov commented 10 years ago

It works, thanks for your help!