This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-07
Channels
- # admin-announcements (3)
- # beginners (133)
- # boot (123)
- # capetown (2)
- # cider (21)
- # cljs-dev (1)
- # cljsrn (2)
- # clojure (32)
- # clojure-czech (1)
- # clojure-russia (2)
- # clojure-spec (72)
- # clojurescript (4)
- # datomic (28)
- # emacs (19)
- # funcool (1)
- # hoplon (10)
- # jobs-rus (1)
- # onyx (1)
- # other-languages (3)
- # protorepl (3)
- # re-frame (10)
- # reagent (76)
- # ring (2)
- # rum (2)
- # spirituality-ethics (61)
- # test-check (2)
- # testing (1)
- # untangled (3)
It was mentioned that an NPM task was required last week so I whipped one up: https://github.com/degree9/boot-npm
@flyboarder: i saw a blog post that
https://medium.com/@tiensonqin/my-experience-with-clojurescript-and-react-native-81bb1d3bb2c4
Was talking about the fact that you need to reset after a while, maybe this task can automate that?
@richiardiandrea: for sure! It will take a bit of expanding on the options but it is possible. I’ll open an issue for reference.
Sounds great
@martinklepsch: exactly. you want both tests and sources in your classpath because they need to be loaded, but you only want to instrument sources, not tests
so if the user munges them together, that would be fine for the running of tests, but it would also print coverage of the test packages which is probably not wanted
this is really over my head. it seems that when i "require" some namespace in "with-eval-in" or (.require pod ...) something different happens (things get put into the classpath?!?) than when i eval code that includes the require ("Could not locate ... on classpath.")
(pod/with-eval-in @pod
(boot.pod/add-classpath ~test-dir)
(doseq [ns '~code-namespaces] (require ns))
(require 'cloverage.coverage)
(cloverage.coverage/-main ~@args))
phew, this finally does the trick.@fossifoo: Cloverage allows selecting namespaces to instrument and test with regexes
In general. I only read last few messages.
scanning the dir for namespaces outside or inside cloverage/the pod doesn't make much difference imho
All the clojure files should already be inside classpath
i think like it is now it's a bit more effort on the task side, but i can simply pass in the test directory or default to "test"
Then your task won't work properly with other boot tasks, e.g. those which create new files in fileset
hmmm. so you think i should pre-wrap and put "test" onto the source-paths? having the user do this seems cumbersome
Existing test tasks presume that tests are already on source-paths (and fileset) and use regex to select the test namespaces
you are right that a task that creates new tests could be possible, even if i don't know of any
from what i see all the existing tasks don't care about the difference and just run tests in all namespaces
Yeah boot-test defaults to that, though regex can be provided
#".*-test" regex would probably work quite well for default filter, that's what I use in boot-alt-test
Boot-test also only works if the tests are in source-paths
But some users modify source-paths using set-env before running tests
I have tests always on source-paths and presume that tasks can deal with that
hello, can anyone please tell me how to configure build.boot so changes to backend are watched and system is auto reset? I work on https://github.com/juxt/edge it has clojurescript auto rebuild and reloaded but not backend when I connect via nrepl and do: (reset) then the backend reloaded as expected how can I have it automatically?
@lambder: you can make a custom boot task that executes reload
Imagine where speak
or notify
would go in the boot pipeline
it needs to be in scope of watch
what's the error?
(deftask dev-system "Develop the server backend. The system is automatically started in the dev profile." [] (require 'reloaded.repl) (let [go (resolve 'reloaded.repl/go) reset (resolve 'reloaded.repl/reset)] (try (require 'user) (go) (reset) ; <<<<<<<< JUST ADDED THIS (catch Exception e (boot.util/fail "Exception while starting the system\n") (boot.util/print-ex e)))) identity)
Exception while starting the system java.lang.IllegalStateException: Can't set!: ns from non-binding thread ... clojure.tools.namespace.repl/do-refresh repl.clj: 95 clojure.tools.namespace.repl/refresh repl.clj: 145 ... reloaded.repl/reset repl.clj: 53 ... boot.user/eval30066/fn/fn boot.user6240738269266896564.clj: 19 boot.user/eval30066/fn boot.user6240738269266896564.clj: 19 ... boot.user/eval30098/fn boot.user6240738269266896564.clj: 21 ... clojure.core/apply core.clj: 630 boot.core/construct-tasks core.clj: 911 ... clojure.core/apply core.clj: 630 boot.core/boot/fn core.clj: 949 clojure.core/binding-conveyor-fn/fn core.clj: 1916 ...
one error is that your boot task should return a fn
example:
(deftask run-main
[]
(with-pre-wrap fileset
(require 'example.core)
((resolve 'excample.core/-main))
fileset))
encapsulate your reloading logic in a single fn that you can resolve and run in this way, that should work
right, but you want to run the code at pipeline-time, not at setup-time, if that makes sense
right
(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'reloaded.repl/reset)] (reset) fileset)))
I think it's safer to require the ns as well
add a println/log message so you see if it's being called 🙂
(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'reloaded.repl/reset)] (reset) fileset)))
(deftask dev "This is the main development entry point." [] (set-env! :dependencies #(vec (concat % '[[reloaded.repl "0.2.1"]]))) (set-env! :source-paths #(conj % "dev")) ;; Needed by tools.namespace to know where the source files are (apply clojure.tools.namespace.repl/set-refresh-dirs (get-env :directories)) (comp (watch) (speak) (sass :output-style :expanded) (reload :on-jsload 'edge.main/init) (cljs-repl :nrepl-opts {:client false :port repl-port :init-ns 'user}) ; this is also the server repl! (cljs :ids #{"edge"} :optimizations :none) (dev-system) (reset-backend) (target)))
maybe something to do with your reset function?
don't know what the error message means sorry
reloaded.repl does some repl magic which doesn't always work
but that should give some idea how to use tools.namespace to reload everything
though it seems to call c.t.n. directly instead of through reloaded.repl
here is another example of using tools.namespace directly: https://github.com/metosin/boot-alt-test/blob/master/src/metosin/boot_alt_test/impl.clj
by the way, I prefer manually reloading namespaces from the editor
that is what I do also
if you use cider, you can set up a keyboard shortcut that does both (reload current buffer, run my.repl/refresh
to recreate Stuart Sierra's component or whatever)
(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'system.repl/reset)] (reset) fileset)))
try using the task in system.boot
java.lang.NullPointerException: boot.user/eval30066/fn/fn/fn boot.user4386639088127429058.clj: 19 adzerk.boot-cljs/eval368/fn/fn/fn boot_cljs.clj: 201
clojure.lang.ExceptionInfo: No such var: dir/scan-dirs data: {:file "system/boot.clj", :line 35} java.lang.RuntimeException: No such var: dir/scan-dirs
This working for anyone?
#!/usr/bin/env boot
(set-env! :dependencies '[[com.datomic/datomic-free "0.9.5390"]])
(require '[datomic.api :as d])
@torgeir: seeing the same issue
bug in latest datomic! 🙂
@torgeir: @pesterhazy not a bug in Datomic. versions >= 0.9.5372 require Clojure 1.8
@anmonteiro: I tried adding Clojure 1.8 as an explicit dependency, didn't help
probably should be in boot.properties
I can definitely see the bug on Clojure 1.7 and not on 1.8
I see
You don't need to define your own boot task to make it work, just include the system task in the pipeline. And configure it appropriately to your use case. If you use component, then that would be something like (system :sys #'dev-system :auto true)
. If you don't have components, that would be simply (system :auto true)
.