jakemcc / test-refresh

Refreshes and reruns clojure.tests in your project.
393 stars 28 forks source link

scan-for-changes crashes on: "Unparsable namespace form: []" #53

Closed Pancia closed 8 years ago

Pancia commented 8 years ago

When I have test-refresh open and I somehow save a file with a [] in its requires it causes this crash. Which I causes me to have to restart test-refresh.

My guess is that a try-catch around src/com/jakemccrary/test_refresh.clj#L18 should help, but I'm not sure what should be returned.

I should have time to fix this sometime this week, but I figured I would put this out there until then.

user=> Exception in thread "main" java.lang.IllegalArgumentException: "Unparsable namespace form:" [], compiling:(/private/var/folders/p2/_mbs7hfj0fs6q74xqxlp4ykm0000gp/T/form-init6939121690210612328.clj:1:125)
    at clojure.lang.Compiler.load(Compiler.java:7239)
    at clojure.lang.Compiler.loadFile(Compiler.java:7165)
    ...
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: "Unparsable namespace form:" []
    at clojure.tools.namespace.parse$deps_from_libspec.invoke(parse.clj:86)
    at clojure.tools.namespace.parse$deps_from_ns_form$fn__326.invoke(parse.clj:91)
        ...
    at clojure.tools.namespace.parse$deps_from_ns_decl.invoke(parse.clj:98)
    at clojure.tools.namespace.file$files_and_deps$fn__339.invoke(file.clj:39)
        ...
    at clojure.tools.namespace.file$files_and_deps.invoke(file.clj:37)
    at clojure.tools.namespace.file$add_files.invoke(file.clj:53)
    at clojure.tools.namespace.dir$update_files.invoke(dir.clj:40)
    at clojure.tools.namespace.dir$scan.doInvoke(dir.clj:62)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at com.jakemccrary.test_refresh$scan_for_changes.invoke(test_refresh.clj:18)
    at com.jakemccrary.test_refresh$monitor_project.invoke(test_refresh.clj:225)
        ...
    ... 11 more
jakemcc commented 8 years ago

Yeah, test-refresh has never really dealt with errors thrown from tools.namespace on malformed ns forms. It would be a nice addition.

I haven't tried to implement it yet but I think scan-for-changes probably needs to return something that indicate what error happened and the previously passed in tracker when an exception happens. Then other code would need to provide a message to the user.

If you don't get to it this week I'll take a stab at it.

jakemcc commented 8 years ago

This was fixed in the referenced PR.