Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClojureScript support #51

Merged
merged 77 commits into from
Feb 23, 2015
Merged

Conversation

imikushin
Copy link
Contributor

Support for ClojureScript made possible by CLJX and adrenaline. Fixes #11.

Clojure code had to be refactored a bit to become more cross-plaform, macro-generated var naming had to be fixed (get rid of gensym) as well as compile time var user metadata support in ClojureScript upstream. The result: we can now use Expectations from ClojureScript:

(ns my-lib.test
  (:require-macros [expectations.cljs :as ecljs])
  (:require [expectations]
            [my-lib.expectations-options]
            [my-lib.core-test]
            [my-lib.util-test]))

(defn -main []
  (ecljs/run-all-tests))

(enable-console-print!)
(set! *main-cli-fn* -main)

jaycfields added a commit that referenced this pull request Feb 23, 2015
@jaycfields jaycfields merged commit d353d98 into clojure-expectations:master Feb 23, 2015
@imikushin
Copy link
Contributor Author

Awesome!

@imikushin
Copy link
Contributor Author

I'd like to help maintain the project.
Is there anything I can do to help cut the new release?

@jaycfields
Copy link
Collaborator

Can you take a look at getting the failure examples failing again? It
should be pretty easy to determine if things are still failing as expected
if you save the output from before I applied the patch and diff it against
the output of what you have failing.

On Monday, February 23, 2015, Ivan Mikushin notifications@github.com
wrote:

I'd like to help maintain the project.
Is there anything I can do to help cut the new release?


Reply to this email directly or view it on GitHub
#51 (comment)
.

Any fool can write a test that helps them today. Good programmers write
tests that help the entire team in the future. http://wewut.com

@imikushin
Copy link
Contributor Author

Sure. I'll take a look.

On Tue, Feb 24, 2015, 17:01 jaycfields notifications@github.com wrote:

Can you take a look at getting the failure examples failing again? It
should be pretty easy to determine if things are still failing as expected
if you save the output from before I applied the patch and diff it against
the output of what you have failing.

On Monday, February 23, 2015, Ivan Mikushin notifications@github.com
wrote:

I'd like to help maintain the project.
Is there anything I can do to help cut the new release?


Reply to this email directly or view it on GitHub
<
https://github.com/jaycfields/expectations/pull/51#issuecomment-75698742>
.

Any fool can write a test that helps them today. Good programmers write
tests that help the entire team in the future. http://wewut.com


Reply to this email directly or view it on GitHub
#51 (comment)
.

@imikushin
Copy link
Contributor Author

I've just diffed the two lein expectations outputs: on 2.0.16 and master (well, I've moved the failing examples to test/cljx before). The differences are basically in set elements ordering: test-results.diff. I'm looking to transform these into real unit tests (expecting failing tests to fail, maybe using doexpect macro) and doing another PR.

@jaycfields
Copy link
Collaborator

I agree, looks good to me too.

On Tue, Feb 24, 2015 at 9:41 AM, Ivan Mikushin notifications@github.com
wrote:

I've just diffed the two lein expectations outputs: on 2.0.16 and master.
The differences are basically in set elements ordering: test-results.diff
https://gist.github.com/imikushin/26bea820e779fefedd15


Reply to this email directly or view it on GitHub
#51 (comment)
.

Any fool can write a test that helps them today. Good programmers write
tests that help the entire team in the future. http://wewut.com

@ptaoussanis
Copy link

May I ask what the status on this is? I see [expectations "2.1.0"] is up on Clojars with this PR included, but I'm struggling to get Cljs tests running.

Trying with `[org.clojure/clojurescript "0.0-3126"]``.

Have an experimental skeleton test ns for this repo.:

  • tests.cljx ns is here.
  • project.clj config is here.

Calling lein clean, lean cljx once, lein cljsbuild once tests I see errors like the following (EDIT: Updated):

Compiling ClojureScript.
Compiling "target/tests.js" from ["src" "target/classes" "test" "target/test-classes"]...
WARNING: expectations is a single segment namespace at line 1 file:/Users/ptaoussanis/.m2/repository/expectations/expectations/2.1.0/expectations-2.1.0.jar!/expectations.cljs
module.js:338
    throw err;
          ^
Error: Cannot find module '/Users/ptaoussanis/Projects/encore/target/tests.js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
Compiling "target/tests.js" failed.
clojure.lang.ExceptionInfo: failed compiling file:target/test-classes/taoensso/encore/tests.cljs {:file #<File target/test-classes/taoensso/encore/tests.cljs>}
    at clojure.core$ex_info.invoke(core.clj:4566)
    at cljs.compiler$compile_file$fn__2994.invoke(compiler.clj:1122)
    at cljs.compiler$compile_file.invoke(compiler.clj:1090)
    at cljs.compiler$compile_root.invoke(compiler.clj:1152)
    at cljs.closure$compile_dir.invoke(closure.clj:367)
    at cljs.closure$eval3332$fn__3333.invoke(closure.clj:407)
    at cljs.closure$eval3268$fn__3269$G__3259__3276.invoke(closure.clj:315)
    at cljs.closure$eval3319$fn__3320.invoke(closure.clj:421)
    at cljs.closure$eval3268$fn__3269$G__3259__3276.invoke(closure.clj:315)
    at cljsbuild.compiler.SourcePaths$fn__3694.invoke(compiler.clj:44)
    at clojure.core$map$fn__4511.invoke(core.clj:2612)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:485)
    at clojure.core$seq__4091.invoke(core.clj:135)
    at clojure.core$apply.invoke(core.clj:626)
    at clojure.core$mapcat.doInvoke(core.clj:2650)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at cljsbuild.compiler.SourcePaths._compile(compiler.clj:44)
    at cljs.closure$build.invoke(closure.clj:1413)
    at cljs.closure$build.invoke(closure.clj:1371)
    at cljsbuild.compiler$compile_cljs$fn__3705.invoke(compiler.clj:58)
    at cljsbuild.compiler$compile_cljs.invoke(compiler.clj:57)
    at cljsbuild.compiler$run_compiler.invoke(compiler.clj:159)
    at user$eval3831$iter__3849__3853$fn__3854$fn__3866.invoke(form-init6028074733401059326.clj:1)
    at user$eval3831$iter__3849__3853$fn__3854.invoke(form-init6028074733401059326.clj:1)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:485)
    at clojure.core$seq__4091.invoke(core.clj:135)
    at clojure.core$dorun.invoke(core.clj:3004)
    at clojure.core$doall.invoke(core.clj:3020)
    at user$eval3831.invoke(form-init6028074733401059326.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6768)
    at clojure.lang.Compiler.eval(Compiler.java:6758)
    at clojure.lang.Compiler.load(Compiler.java:7195)
    at clojure.lang.Compiler.loadFile(Compiler.java:7151)
    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: clojure.lang.ExceptionInfo: Unable to resolve var: repeatedly* in this context at line 28 target/test-classes/taoensso/encore/tests.cljs {:tag :cljs/analysis-error, :file "target/test-classes/taoensso/encore/tests.cljs", :line 28, :column 36}
    at clojure.core$ex_info.invoke(core.clj:4566)
    at cljs.analyzer$error.invoke(analyzer.clj:379)
    at cljs.analyzer$error.invoke(analyzer.clj:376)
    at cljs.analyzer$confirm_var_exists_throw$fn__1206$fn__1207.invoke(analyzer.clj:419)
    at cljs.analyzer$confirm_var_exists.invoke(analyzer.clj:413)
    at cljs.analyzer$confirm_var_exists_throw$fn__1206.invoke(analyzer.clj:417)
    at cljs.analyzer$resolve_var.invoke(analyzer.clj:467)
    at cljs.analyzer$eval1289$fn__1291.invoke(analyzer.clj:656)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$analyze_vector$fn__1852$fn__1853.invoke(analyzer.clj:1856)
    at clojure.core$map$fn__4511.invoke(core.clj:2612)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:485)
    at clojure.lang.LazilyPersistentVector.create(LazilyPersistentVector.java:31)
    at clojure.core$vec.invoke(core.clj:356)
    at cljs.analyzer$analyze_vector$fn__1852.invoke(analyzer.clj:1856)
    at cljs.analyzer$analyze_vector.invoke(analyzer.clj:1856)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1927)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$analyze_let$fn__1469$fn__1471.invoke(analyzer.clj:1078)
    at cljs.analyzer$analyze_let$fn__1469.invoke(analyzer.clj:1077)
    at cljs.analyzer$analyze_let.invoke(analyzer.clj:1069)
    at cljs.analyzer$eval1482$fn__1483.invoke(analyzer.clj:1122)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1835)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1835)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1835)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1835)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$eval1456$fn__1458.invoke(analyzer.clj:1057)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$analyze_fn_method$fn__1410.invoke(analyzer.clj:933)
    at cljs.analyzer$analyze_fn_method.invoke(analyzer.clj:932)
    at cljs.analyzer$eval1415$fn__1417$fn__1420.invoke(analyzer.clj:969)
    at clojure.core$map$fn__4511.invoke(core.clj:2614)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:485)
    at clojure.core$seq__4091.invoke(core.clj:135)
    at clojure.core$map$fn__4511.invoke(core.clj:2606)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:485)
    at clojure.core$seq__4091.invoke(core.clj:135)
    at clojure.core$apply.invoke(core.clj:626)
    at cljs.analyzer$eval1415$fn__1417.invoke(analyzer.clj:970)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1835)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$eval1520$fn__1522.invoke(analyzer.clj:1208)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1911)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1910)
    at cljs.analyzer$eval1456$fn__1458.invoke(analyzer.clj:1058)
    at clojure.lang.MultiFn.invoke(MultiFn.java:251)
    at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1833)
    at cljs.analyzer$analyze$fn__1881.invoke(analyzer.clj:1925)
    at cljs.analyzer$analyze.invoke(analyzer.clj:1918)
    at cljs.compiler$compile_file_STAR_$fn__2962.invoke(compiler.clj:1008)
    at cljs.compiler$with_core_cljs.invoke(compiler.clj:950)
    at cljs.compiler$compile_file_STAR_.invoke(compiler.clj:970)
    at cljs.compiler$compile_file$fn__2994.invoke(compiler.clj:1107)
    ... 45 more

So the run is choking on (set! *main-cli-fn* (fn -main [] (expect-cljs/run-all-tests))).

repeatedly* is a macro var that I define in my (.cljx->).clj ns. It's not present in my (.cljx->).cljs ns.

So it looks like expectations.cljs/run-all-tests is picking up a macro var in my .clj ns (repeatedly*), then trying to refer to it from ClojureScript (where it doesn't exist).

Any idea if I'm doing something obviously wrong (config maybe?), or is the Cljs support not quite ready yet?

Thanks a lot for any info! Cheers :-)

@imikushin
Copy link
Contributor Author

Peter, I'm taking a look. Will definitely follow up on this.
Cheers!

@ptaoussanis
Copy link

Thanks Ivan, much appreciated! Just let me know if you can use any other info.

@imikushin
Copy link
Contributor Author

@ptaoussanis this is a bug introduced in a newer ClojureScript release. I'll try to triangulate and hack a workaround.

@imikushin
Copy link
Contributor Author

[org.clojure/clojurescript "0.0-2985"] is the last release without this bug

@ptaoussanis
Copy link

this is a bug introduced in a newer ClojureScript release. I'll try to triangulate and hack a workaround.

Oh, interesting. I've been having fun with ClojureScript today myself. Thanks for looking into this. No urgency btw, please take your time.

@imikushin
Copy link
Contributor Author

Please take a look: taoensso/encore#12
Just to help with a working expectations setup for cljs. Obviously, some documentation is overdue.
I'll follow up on fixing the problem with the newer cljs versions.

imikushin added a commit to imikushin/expectations that referenced this pull request Apr 16, 2015
Since 0.0-2985 ClojureScript introduced macro symbols in its analysis map and expectation used them to construct vars for test defs, hence the failure described here: clojure-expectations#51 (comment)
@imikushin
Copy link
Contributor Author

@jaycfields @ptaoussanis I've finally found some time to take a close look at the issue. Please, take a look at PR #55

@jaycfields
Copy link
Collaborator

merged. thx Ivan

@ptaoussanis
Copy link

Thank you! Much appreciated :-)

@imikushin
Copy link
Contributor Author

You're welcome! :)
Jay, can you cut the 2.1.1 release with that fix for us? ;)

@jaycfields
Copy link
Collaborator

done. Sorry, missed that step.

On Thu, Apr 16, 2015 at 8:05 AM, Ivan Mikushin notifications@github.com
wrote:

You're welcome! :)
Jay, can you cut the 2.1.1 release with that fix for us? ;)


Reply to this email directly or view it on GitHub
#51 (comment)
.

Any fool can write a test that helps them today. Good programmers write
tests that help the entire team in the future. http://wewut.com

@imikushin
Copy link
Contributor Author

Wow, that was fast!!
Thanks a ton!

@jaycfields
Copy link
Collaborator

No worries, thx for the updates. :)

On Thu, Apr 16, 2015 at 8:08 AM, Ivan Mikushin notifications@github.com
wrote:

Wow, that was fast!!
Thanks a ton!


Reply to this email directly or view it on GitHub
#51 (comment)
.

Any fool can write a test that helps them today. Good programmers write
tests that help the entire team in the future. http://wewut.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make Expectations work in Clojurescript
3 participants