marick / lein-midje

Leiningen plugin for Midje
MIT License
77 stars 29 forks source link

lein midje command doesn't work in 2.0.3 #32

Closed empperi closed 11 years ago

empperi commented 11 years ago

Command "lein midje" doesn't work at all in 2.0.3. Downgrading lein-midje to 2.0.1 fixes the problem. To replicate the issue create an empty project with nothing at all with a following project.clj:

(defproject test-prj "0.1.0-SNAPSHOT"
  :profiles {:dev {:plugins [[lein-midje "2.0.3"]]
                   :dependencies [[midje "1.4.0"]]}})

and just type "lein midje". You'll face a following stacktrace:

Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: Unsupported character: \\*
        at clojure.lang.LispReader.read(LispReader.java:215)
        at clojure.core$read.invoke(core.clj:3346)
        at clojure.core$read.invoke(core.clj:3344)
        at clojure.main$eval_opt.invoke(main.clj:295)
        at clojure.main$initialize.invoke(main.clj:316)
        at clojure.main$null_opt.invoke(main.clj:349)
        at clojure.main$main.doInvoke(main.clj:427)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:419)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.Var.applyTo(Var.java:532)
        at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unsupported character: \\*
        at clojure.lang.Util.runtimeException(Util.java:170)
        at clojure.lang.LispReader$CharacterReader.invoke(LispReader.java:951)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.readDelimitedList(LispReader.java:1126)
        at clojure.lang.LispReader$ListReader.invoke(LispReader.java:962)
        at clojure.lang.LispReader.read(LispReader.java:180)
        ... 11 more

Environment: Windows 7 x64, Java 1.7.0_09 32-bit, Leiningen 2.0.0-preview10.

This bug occurs also with Midje 1.5-alpha3.

marick commented 11 years ago

That is very peculiar. It's complaining about an illegal character, yet \* is a perfectly legal character. Here is the code with that character in 2.0.3:

(defn- make-classpath-getter []
  `(fn [namespaces# paths#]
     (if (empty? namespaces#)
       (mapcat bultitude.core/namespaces-in-dir paths#)
       (mapcat #(if (= \* (last %))
                  (bultitude.core/namespaces-on-classpath :prefix (apply str (butlast %)))
                  [(symbol %)])
               namespaces#))))

Here is the code in 2.0.1:


(defn- get-namespaces [namespaces]
  (mapcat #(if (= \* (last %))
             (namespaces-on-classpath :prefix (apply str (butlast %)))
             [(symbol %)])
    namespaces))

You can see that the code immediately surrounding \* is the same as before. What happens if you past this code into the repl?

(defn- make-classpath-getter []
  `(fn [namespaces# paths#]
     (if (empty? namespaces#)
       (mapcat identity paths#)
       (mapcat #(if (= \* (last %))
                  (identity :prefix (apply str (butlast %)))
                  [(symbol %)])
               namespaces#))))

You can find it as raw text here: https://gist.github.com/4401553

It seems awfully unlikely, but is it possible the lein-midje jar file got corrupted? Can you check the SHA1 checksum? I don't know how you do that on Windows (or where Maven downloads get stored). On OSX, it's like this:

1158 $ cd ~/.m2/repository/lein-midje/lein-midje/2.0.3/
1159 $ shasum lein-midje-2.0.3.jar
cae98008610dad8ab041dedfbeada0f63efbc5cc  lein-midje-2.0.3.jar
1160 $ cat lein-midje-2.0.3.jar.sha1
cae98008610dad8ab041dedfbeada0f63efbc5cc
marick commented 11 years ago

P.S. Making the empty directory with the project.clj you gave produces this for me (on OSX):

1167 $ lein midje
All claimed facts (0) have been confirmed. 
empperi commented 11 years ago

Hi, thanks for looking at this.

Copy-pasting your example function to REPL opened with 'lein repl' works just fine. Also calling that function produces perfectly sensible results. I also checked the SHA1 checksum for the jar package and it too is correct. The problem persists though and currently I'm forced to use 2.0.1 of lein-midje.

I understand that this is going to be really hard for you to fix since you're on OSX and you cannot replicate the issue. I would be grateful though if someone could fix this issue.

marick commented 11 years ago

If you do a (usemidje.repl)` at a REPL prompt, do you get an error? I ask because the code in midje-repl is due to be replaced with code that uses the new midje.repl namespace. So the problem may soon go away with that code.

empperi commented 11 years ago

It complains about a missing class, so yes I do get an error. I tried with lein-midje 2.0.3 and with both 1.4.0 and 1.5-alpha3 of midje. Hopefully this is good news?

marick commented 11 years ago

On Dec 29, 2012, at 10:35 AM, Niklas Collin notifications@github.com wrote:

It complains about a missing class, so yes I do get an error. I tried with lein-midje 2.0.3 and with both 1.4.0 and 1.5-alpha3 of midje. Hopefully this is good news?

I've pushed out a 2.0.3 and a 3.0-alpha1. Do either of those work? With the new midje 1.5-alpha5, what happens when you do a (load-facts :all)?

If there are errors, please paste the output.


Occasional consulting on programming technique Contract programming in Ruby and Clojure Latest book: /Functional Programming for the Object-Oriented Programmer/ https://leanpub.com/fp-oo

empperi commented 11 years ago

With lein-midje 3.0-alpha1 and midje 1.5-alpha5 it works, no errors. With any of the older version combo it dies either on \* character or on not finding the midje/repl.clj (or appropriate class). So it seems like the new versions are going to fix this. Will continue using the alpha stage versions with this little project of mine and will report if I face other problems. At work I think it's best we stay on older versions for now.

Closing this issue. Thanks man :)