We have a load of midje tests setup for Clojure, they currently work with lein midje.
We want to use Kaocha-midje, and then the rest of kaocha, but cannot get any tests to be found using Kaocha.type/midje.
Heres the project.clj add-ins:
:profiles {:dev {:dependencies [[midje "1.9.9"]
[lambdaisland/kaocha "1.0.861"]
[lambdaisland/kaocha-midje "0.0-5"]}}
:aliases {"kaocha" ["run" "-m" "kaocha.runner"]}
There is also the test.edn file
{:tests [
{:type :kaocha.type/midje
:id :midje
:source-paths ["src"]
:test-paths ["test/unit/directory/path/example_midje_test.clj"]}
]
:kaocha/fail-fast? false
:kaocha/color? true
:kaocha.plugin.randomize/randomize? false
:kaocha/reporter [kaocha.report/dots]
:kaocha/plugins [:kaocha.plugin/randomize
:kaocha.plugin/filter
:kaocha.plugin/capture-output]}
example_midje_test.clj is the example from https://github.com/lambdaisland/kaocha-midje/blob/master/test/midjetest/the_test.clj
but I have also tried one of our existing tests, and also tried test/unit so it can find them all, but it gives Spec errors, but none of our tests currently fail.
This is the error output for the test/unit test-path
WARNING: No tests were found, make sure :test-paths and :ns-patterns are configured correctly in tests.edn.
Also posted here https://github.com/lambdaisland/kaocha/issues/230
Which said the midje kaocha is experimental at best and suggested moving to something else.
Related
This is asking for help regarding the same question as How to change Clojure or Lein's Clojure default version?
but is not an answer to that question. Should I have nevertheless have written it as an answer under that thread?
Specifying a Clojure version to be used when the "(lein repl)" command is issued outside of a project directory seems to be a natural thing to want. Of course there may be good design reasons for not allowing it, but do you think an error message like the following,
to be displayed when Leiningen detects that the ~/.lein/profiles.clj (or other relevant profile files) specify a different Clojure version from the one hard coded into Leiningen,
would be a good idea?
"specifying the Clojure version to be used with certain software, such as tools.nrepl and clojure-complete, is only allowed when this command is issued within a project directory"
A lot of people apparently have spent a lot of time on Stack Overflow trying to find out how to do this.
References:
"Updating ~/.lein/profiles.clj to {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0"]]}} does not seem to work. – Petrus Theron Jan 10 2018 at 9:05" How do you change Clojure version in Leiningen and LightTable?
"I asked technomancy on IRC just now. He said: "REPL's outside projects are hard coded to lein's version of clojure". – David J. Feb 24 '14 at 19:52" How to change Clojure or Lein's Clojure default version?
"this ^:displace trick will not work with tools.nrepl or clojure-complete." https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
How to upgrade nrepl version of leiningen?
I think you may try to declare different profiles in your project.clj where each of them has its own Clojure version. For example:
:profiles
{;; :default [:base :system :user :provided :dev]
:server-jvm {:jvm-opts ^:replace ["-server"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}}
Now that, when running any Lein command, specify a profile as follows:
lein with-profile 1.7 repl
The REPL session of Clojure 1.7 should start.
I grabbed that fragment from carmine sources. The official Lein profiles manual also has the same example.
I have a project containing both Clojure & ClojureScript code. I would like to include unoptimized ClojureScript when I run my server via lein ring server and optimized ClojureScript otherwise. What is the idiomatic way to do this?
I am using:
[[bidi "1.19.0"]
[hiccup "1.0.5"]
[org.clojure/clojure "1.7.0-beta3"]
[org.clojure/clojurescript "0.0-3269"]]
[[lein-cljsbuild "1.0.4"]
[lein-ring "0.9.4"]]
My handler is just a simple one:
(def app (-> ["/" {:get {"" index-view}}]
(compile-route)
(make-handler)))
and this is my server directive:
:ring {:handler webapp.core/app}
I am looking for a way to be able to do this in my views:
(dev-server? request) ;; => true if it's a development server, otherwise false.
The idiomatic way to do this is to use leiningen profiles, using the :dev profile. You can then ensure inside the dev profile that your ClojureScript build is happening without optimization, cf. the leiningen cljsbuild compilation profiles.
If you want to be able to identify the devserver running, you can use environ -- include :env {:dev true} in your :dev profile and then in your code you can just call (env :dev). You might want to take a look at the reagent-template for inspiration.
As a clojure noob, I am trying to use cascalog to parse a large CSV file. Here is my minimal project.clj:
(defproject org.example/sample "1.0.0-SNAPSHOT"
:description "extract fields from a certain csv file."
:dependencies [
[cascalog "2.0.0"]
[clojure-csv/clojure-csv "2.0.1"]
]
:profiles { :dev {:dependencies [[org.apache.hadoop/hadoop-core "1.1.2"]]}}
:jvm-opts ["-Xms768m" "-Xmx768m"]
)
lein deps succeeds, but when I run (use 'cascalog.api) inside lein repl, then I get the following error:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: combinations in this context, compiling:(jackknife/seq.clj:12)
Removing clojure-csv from project.clj prevents the error, but I can run (use 'clojure-csv.core) inside lein repl without error.
One other person on the internet appears to have had this problem, but has not posted a solution. What is going on here, and how should I fix it? I'd be eternally grateful if someone could help.
I am seriously pulling my hair right now! I am a total noob at clojure: I can't seem to be able to get a simple clojurescript compilation done without this error:
ERROR: JSC_MISSING_PROVIDE_ERROR. required "clojure.core.async" namespace never provided at /home/jldupont/workspace/$someproject/target/cljsbuild-compiler-0/domain2/main.js line 4 : 0
I've got the following project.clj file:
(defproject $someproject "0.1"
:description "some project..."
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojurescript "0.0-2030"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]
]
:plugins [[lein-cljsbuild "0.3.2"]]
:cljsbuild {
:builds [{:id "domain2"
:source-paths ["src/cljs/model2/domain"]
:compiler {:output-to "src/assets/js/model2/domain/domain2.js"
:optimizations :advanced
:pretty-print true}
}
]
}
)
Everytime I use lein cljsbuild auto I get the error quoted above.
Please help!
Update
I've looked in my ~/.m2 directory and the dependencies ( in this case core.async ) are present.
Update 2
It would appear that it is the Google Closure Compiler that spews out this error message. Not sure how to provide it a path to the dependencies...
As mentioned in my comment above: if you want to use core.async with ClojureScript you have to require the namespace cljs.core.async (instead of Clojure's clojure.core.async).
Im working on compiling jars from a local repository in leiningen. This works in my project.clj:
:repositories {"local" ~(str (.toURI (java.io.File. "local_mvn_repo")))}
but this fails:
:repositories [["local" (str (.toURI (java.io.File. "local_mvn_repo")))]]
$ lein deps
java.lang.UnsupportedOperationException: nth not supported on this type: Symbol
Even though the latter looks in compliance with the official example. My question is this:
What does the ~ do above, which do I need it, and why can't i use the vector form?
The ~ is the unquoting function in this case, it tells lieningen to run the form after it and use the value produced by running it instead of trying to use it directly.
The first example if the format for Leiningen version 1.x while the second from is the newer form and is failing because it is missing the ~ and some { }
:repositories [["local" {:url ~(str (.toURI (java.io.File. "local_mvn_repo")))}]]
ps: I'm not sure if the map form is required and I'm assuming you are using lein2