weavejester / eftest

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

Add support for reporting to a file via project.clj #25

Closed jcf closed 7 years ago

jcf commented 7 years ago

Hi James,

I think this will work as-is but can't test it automatically very easily because I can't get Leiningen to pull in an unreleased, local version of both eftest and lein-eftest (I don't think plugins are supported when it comes to checkouts?).

I've added a comment explaining why I've used an or as opposed to whatever is in (-> project :eftest :report) and that I'm duplicating the default reporter logic with this change. I'm not sure if you want to address the latter?

If you have an idea how to automate testing this I'm happy to implement something, but kinda stumped given the logic is inside a Leiningen plugin.

All the best!

weavejester commented 7 years ago

Thanks! Could you add a quick note to the README about the new option as part of this PR? That would help both describe the functionality of the patch, and tell people about it once it is merged.

jcf commented 7 years ago

@weavejester I've added something to the README.

jcf commented 7 years ago

Testing this out now and it needs a bit of tweaking around picking the default reporter function.

java.lang.ClassNotFoundException: eftest.report.progress, compiling:(leiningen/eftest.clj:78:18)
    at clojure.lang.Compiler.analyze(Compiler.java:6688)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:2805)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6319)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6269)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6319)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5380)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3972)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6866)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:589)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler.eval(Compiler.java:6931)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.loadResourceScript(RT.java:363)
    at clojure.lang.RT.load(RT.java:453)
    at clojure.lang.RT.load(RT.java:419)
    at clojure.core$load$fn__5677.invoke(core.clj:5893)
    at clojure.core$load.invokeStatic(core.clj:5892)
    at clojure.core$load.doInvoke(core.clj:5876)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5697)
    at clojure.core$load_one.invoke(core.clj:5692)
    at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
    at clojure.core$load_lib.invokeStatic(core.clj:5736)
    at clojure.core$load_lib.doInvoke(core.clj:5717)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$load_libs.invokeStatic(core.clj:5774)
    at clojure.core$load_libs.doInvoke(core.clj:5758)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$require.invokeStatic(core.clj:5796)
    at clojure.core$require.doInvoke(core.clj:5796)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at leiningen.core.utils$require_resolve.invokeStatic(utils.clj:91)
    at leiningen.core.utils$require_resolve.invoke(utils.clj:84)
    at leiningen.core.utils$require_resolve.invokeStatic(utils.clj:94)
    at leiningen.core.utils$require_resolve.invoke(utils.clj:84)
    at leiningen.core.main$lookup_task_var.invokeStatic(main.clj:68)
    at leiningen.core.main$lookup_task_var.invoke(main.clj:64)
    at leiningen.core.main$resolve_task.invokeStatic(main.clj:279)
    at leiningen.core.main$resolve_task.invoke(main.clj:275)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at lein_shorthand.plugin$resolve_task_hook.invokeStatic(plugin.clj:42)
    at lein_shorthand.plugin$resolve_task_hook.doInvoke(plugin.clj:40)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at robert.hooke$compose_hooks$fn__11994.doInvoke(hooke.clj:40)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at robert.hooke$run_hooks.invokeStatic(hooke.clj:46)
    at robert.hooke$run_hooks.invoke(hooke.clj:45)
    at robert.hooke$prepare_for_hooks$fn__11999$fn__12000.doInvoke(hooke.clj:54)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at leiningen.core.main$resolve_task.invokeStatic(main.clj:283)
    at leiningen.core.main$resolve_task.invoke(main.clj:275)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at lein_shorthand.plugin$resolve_task_hook.invokeStatic(plugin.clj:42)
    at lein_shorthand.plugin$resolve_task_hook.doInvoke(plugin.clj:40)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at robert.hooke$compose_hooks$fn__11994.doInvoke(hooke.clj:40)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at robert.hooke$run_hooks.invokeStatic(hooke.clj:46)
    at robert.hooke$run_hooks.invoke(hooke.clj:45)
    at robert.hooke$prepare_for_hooks$fn__11999$fn__12000.doInvoke(hooke.clj:54)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at leiningen.core.main$apply_task.invokeStatic(main.clj:313)
    at leiningen.core.main$apply_task.invoke(main.clj:308)
    at leiningen.with_profile$with_profiles_STAR_.invokeStatic(with_profile.clj:14)
    at leiningen.with_profile$with_profiles_STAR_.invoke(with_profile.clj:8)
    at leiningen.with_profile$apply_task_with_profiles.invokeStatic(with_profile.clj:53)
    at leiningen.with_profile$apply_task_with_profiles.invoke(with_profile.clj:45)
    at leiningen.with_profile$with_profile$fn__12053.invoke(with_profile.clj:85)
    at clojure.core$mapv$fn__6953.invoke(core.clj:6627)
    at clojure.core.protocols$fn__6755.invokeStatic(protocols.clj:167)
    at clojure.core.protocols$fn__6755.invoke(protocols.clj:124)
    at clojure.core.protocols$fn__6710$G__6705__6719.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
    at clojure.core.protocols$fn__6738.invokeStatic(protocols.clj:75)
    at clojure.core.protocols$fn__6738.invoke(protocols.clj:75)
    at clojure.core.protocols$fn__6684$G__6679__6697.invoke(protocols.clj:13)
    at clojure.core$reduce.invokeStatic(core.clj:6545)
    at clojure.core$mapv.invokeStatic(core.clj:6618)
    at clojure.core$mapv.invoke(core.clj:6618)
    at leiningen.with_profile$with_profile.invokeStatic(with_profile.clj:85)
    at leiningen.with_profile$with_profile.doInvoke(with_profile.clj:63)
    at clojure.lang.RestFn.invoke(RestFn.java:445)
    at clojure.lang.Var.invoke(Var.java:388)
    at clojure.lang.AFn.applyToHelper(AFn.java:160)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at leiningen.core.main$partial_task$fn__5932.doInvoke(main.clj:272)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at leiningen.core.main$apply_task.invokeStatic(main.clj:322)
    at leiningen.core.main$apply_task.invoke(main.clj:308)
    at leiningen.core.main$resolve_and_apply.invokeStatic(main.clj:328)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:324)
    at leiningen.core.main$_main$fn__5998.invoke(main.clj:401)
    at leiningen.core.main$_main.invokeStatic(main.clj:394)
    at leiningen.core.main$_main.doInvoke(main.clj:391)
    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.core$apply.invokeStatic(core.clj:646)
    at clojure.main$main_opt.invokeStatic(main.clj:314)
    at clojure.main$main_opt.invoke(main.clj:310)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:394)
    at clojure.lang.AFn.applyToHelper(AFn.java:165)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: eftest.report.progress
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at clojure.lang.RT.classForName(RT.java:2168)
    at clojure.lang.RT.classForName(RT.java:2177)
    at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1030)
    at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7056)
    at clojure.lang.Compiler.analyze(Compiler.java:6648)
jcf commented 7 years ago

@weavejester I've testing out the new and improved work with quoted options and it works in a real world codebase.

weavejester commented 7 years ago

If you feel this is ready to be merged, could you squash your commits?

jcf commented 7 years ago

If you feel this is ready to be merged

@weavejester pressure! :sweat: :wink:

I've squashed the commits down, and I got some good JUnit output in an XML file when I tried this out.

I'd like to add an integration test that runs some real tests with a project.clj file and asserts there's valid XML coming out but maybe that's overkill? What do you think, Mr. Reeves?