Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jun 4, 2022. It is now read-only.

Add lumo.repl/get-arglists #88

Merged
merged 3 commits into from
Mar 8, 2017
Merged

Conversation

arichiardi
Copy link
Collaborator

Hi Antonio, I added this utility function because inf-clojure needs it.

Oddily, the tests are not working on my machine, but the same in the yarn dev repl works:

cljs.user=> (require '[cljs.test :as test :refer-macros [is]])
nil
cljs.user=> (is (= (lumo/get-arglists "cljs.core/map") '([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
true

I could not figure out why, but lumo.repl/resolve-var calls to cljs.analyzer both fail with #object[Error Error: No protocol method IDeref.-deref defined for type null: ]. Again, this happenes only in boot test, maybe it is running with another version of ClojureScript.

In any case, I'll be waiting for your comments 😉

@anmonteiro
Copy link
Owner

That doesn't make sense to me, but I just pushed an update to CLJS. can you rebase on current master to see if that fixes it?

@arichiardi
Copy link
Collaborator Author

A test still does not pass:

Testing lumo.repl-tests

FAIL in (test-get-arglists) (at /home/arichiardi/.boot/cache/tmp/home/arichiardi/git/lumo/ie3/-dde9ud/cljs_test/generated_test_suite.out/cljs/test.cljs:469:9)
expected: (= (lumo/get-arglists "when") (quote ([test & body])))
  actual: (not (= nil ([test & body])))

Probably resolve-var cannot resolve it, I am checking.

@arichiardi arichiardi force-pushed the get-arglists branch 2 times, most recently from d337330 to ce71a64 Compare February 27, 2017 02:06
(if-not (:macro var)
(:arglists var)
;; filtering &env &form for macros
(map #(filterv (complement '#{&env &form}) %)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do this because apparently in the real repl that symbols have &env and `&form as arglists, while in the tests they don't. I know that I fixed a symptom and I haven't investigated the cause but hopefully we'll figure it out at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference on this, I opened CLJS-1958, but it is probably better to have it here, not upstream I guess (see comment).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After convo on Slack, this solution will be implemented instead of this ugly hack.

(is (= (lumo/get-arglists "cljs.core/map") '([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
(is (= (lumo/get-arglists "map") '([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
(is (= (lumo/get-arglists "clojure.core/when") '([test & body])))
;; (is (= (lumo/get-arglists "when") '([test & body]))) ;; cannot test it calling lumo.repl/init works in tests
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so that I don't forget, the problem here was that we don't have this key for when in the compiler env unless we are able to load the compiler cache (call to lumo.repl/init). We cannot load the compiler cache because lumo.repl/init triggers a $$LUMO_GLOBALS.load is not a function.

@arichiardi
Copy link
Collaborator Author

I fixed this with the approach in doc* but again without analysis cache the tests are not passing. It is a pity but unless I hook up the .load function there is nothing I can do I think.

@anmonteiro
Copy link
Owner

@arichiardi I don't see those changes. Did you forget to push?

@arichiardi
Copy link
Collaborator Author

arichiardi commented Mar 3, 2017

No but soon I will (push not forget 😀)

@anmonteiro
Copy link
Owner

So one thing you can do is just call cljs.js/load-core-analysis-cache! with a dump of the when macro for testing purposes only.

@arichiardi
Copy link
Collaborator Author

Probably for this unit test yes, I was wondering if more broadly it is worth just setting the load from the hardcoded path to the cache...Generated in a fixture and dumped in a temp folder...Probably a way bigger task but worth doing at some point.

@anmonteiro
Copy link
Owner

Sure but we don't wanna do that for now. Seems like a too big cost for very little benefit

@arichiardi
Copy link
Collaborator Author

Agree

@arichiardi
Copy link
Collaborator Author

Finally ready for review! I ended up implementing the full analysis cache load because it was relatively straight forward. I am looking forward to your comments 👍

@arichiardi arichiardi force-pushed the get-arglists branch 2 times, most recently from a4c89c3 to 86da71e Compare March 8, 2017 00:44
.gitignore Outdated
lumo-cache/
third_party/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed anymore, better to keep the diff clean and not touch this file

(catch :default e nil)))

(def cljs-core-cache-path "generated_test_suite.out/cljs/core.cljs.cache.json")
(def cljs-core-macros-cache-path "generated_test_suite.out/cljs/core$macros.cljc.cache.json")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal, but this is relying on implementation details of boot-cljs-test which is subject to change. Can we add an explicit ids option to the test task in build.boot? Something like :ids #{"test_out"}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can, but the path will always be hardcoded anyways right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but at least we have control over its name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will do

This patch adds a :once fixture which loads the analysis cache for
`cljs.core` so that it will be easier to test features that need macro
ast data to be loaded.
(catch :default e nil)))

;; For the cache source folder, the test id needs to become:
;; lumo_test/test_suite => test_suite.out/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a comment in there

@anmonteiro anmonteiro merged commit ad0a187 into anmonteiro:master Mar 8, 2017
@arichiardi arichiardi deleted the get-arglists branch March 8, 2017 05:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.