Skip to content

Fix the build / honor the refresh-dirs #298

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

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

vemv
Copy link
Member

@vemv vemv commented Apr 13, 2021

Fixes the build with the following strategy:

  • isolate the "Lein plugin" part to its own source path
    • this makes it possible to exercise older versions of Clojure, which don't have e.g. *print-namespace-map*, which the Lein implementation can assume.
    • This is also the strategy followed in Eastwood (to name another project that is both a library and a Lein plugin at the same time)
  • When tools.namespace refresh-dirs are set, don't analyze files outside those refresh dirs.
    • This is a quality of life improvement anyway. A properly set up Clojure project (that is using tools.namespace) tends to have the refresh-dirs set.
    • This way end users don't have extraneous code being possibly analyzed: examples, drafts, production scripts, etc all of which are dangerous to analyze (because analysis == execution of top-level forms).
    • For this to work, tools.namespace is resolved in runtime.
  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (run lein do clean, test)
  • Code inlining with mranderson works and tests pass with inlined code (run ./build.sh install -- takes a long time)
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

(ns global-test-setup
"This namespace's contents will be automatically loaded by `lein test` (or any test runner)."
(:require
[refactor-nrepl.inlined-deps.toolsnamespace.v1v1v0.clojure.tools.namespace.repl :refer [set-refresh-dirs]]))
Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally this would be:

- refactor-nrepl.inlined-deps.toolsnamespace.v1v1v0.clojure.tools.namespace.repl
+ clojure.tools.namespace.repl

but I couldn't wait get it to work. It looked like mranderson :expositions would do the trick but nope?

Copy link
Member

Choose a reason for hiding this comment

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

It seems like this old issue to me benedekfazekas/mranderson#5

@@ -37,8 +55,28 @@
:when ((set deps) ns)]
file)))

(defn- in-refresh-dirs? [refresh-dirs file]
Copy link
Member Author

Choose a reason for hiding this comment

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

Can add a unit test to this one. For now I didn't b/c my reasoning was that this is a private helper, and often private helpers are left untested.

Don't know how clojure-emacs folks tend to approach these - would be happy to tweak

Copy link
Member

Choose a reason for hiding this comment

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

I don't typically add tests for private helpers.

Fixes the build with the following strategy:

* isolate the "Lein plugin" part to its own source path
  * this makes it possible to exercise older versions of Clojure, which don't have e.g. `*print-namespace-map*`, which the Lein implementation can assume.
* When tools.namespace `refresh-dirs` are set, don't analyze files outside those refresh dirs.
  * This is a quality of life improvement anyway. A properly set up Clojure project (that is using tools.namespace) tends to have the `refresh-dirs` set.
  * This way end users don't have extraneous code possibly analyzed code: examples, drafts, production scripts, etc all of which is dangerous to analyze (because analysis == execution).
  * For this to work, tools.namespace is resolved in runtime.
    * `cider-refresh` does the same: https://git.io/JOYUT
@bbatsov bbatsov merged commit ff52d03 into clojure-emacs:master Apr 14, 2021
@bbatsov
Copy link
Member

bbatsov commented Apr 14, 2021

The changes look good to me. Thanks!

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.

2 participants