views:

90

answers:

1

I am writing a small Clojure project using leiningen with the following directory structure:

project
+ src
  + org/example/project/core.clj
+ test
  + org/example/project/core.clj

When I run lein test, it reports that it ran 0 tests with 0 failures, but I purposely put a test designed to fail in the test/.../core.clj file.

I added the line :test-path test to my project.clj file and when I re-ran, got the error:

Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.Symbol (NO_SOURCE_FILE:0)
    at clojure.lang.Compiler.eval(Compiler.java:5440)
    at clojure.lang.Compiler.eval(Compiler.java:5391)
    at clojure.core$eval.invoke(core.clj:2382)
    at clojure.main$eval_opt.invoke(main.clj:235)
    at clojure.main$initialize.invoke(main.clj:254)
    at clojure.main$script_opt.invoke(main.clj:270)
    at clojure.main$main.doInvoke(main.clj:354)
    at clojure.lang.RestFn.invoke(RestFn.java:458)
    at clojure.lang.Var.invoke(Var.java:377)
    at clojure.lang.AFn.applyToHelper(AFn.java:174)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.Symbol
    at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:471)
    at clojure.java.io$fn__7328$G__7323__7333.invoke(io.clj:34)
    at clojure.java.io$file.invoke(io.clj:401)
    at leiningen.util.ns$namespaces_in_dir.invoke(ns.clj:38)
    at leiningen.test$test.doInvoke(test.clj:45)
    at clojure.lang.RestFn.invoke(RestFn.java:411)
    at clojure.lang.Var.invoke(Var.java:365)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.core$apply.invoke(core.clj:542)
    at leiningen.core$apply_task.invoke(core.clj:156)
    at leiningen.core$_main.doInvoke(core.clj:212)
    at clojure.lang.RestFn.applyTo(RestFn.java:138)
    at clojure.core$apply.invoke(core.clj:540)
    at leiningen.core$_main.invoke(core.clj:217)
    at user$eval167.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:5424)
    ... 11 more

I am running Clojure 1.2 and the latest lein (1.3.1).

Looks like a problem with either clojure.core or the lein code.

+2  A: 

As for the source layout. I think you basically shadow your test with the real core.clj file. That's probably why clojure.test doesn't find any tests. Did you try a different namespace and file name? eg. test/example/project/test_core.clj.

kotarak
@kotarak: That worked. I thought the name should not matter. The file and namespace are now `test_core`.
Ralph
@Ralph: well, src and test are not part of the namespace. Some both files basically look the same to the clojure process. So the first found will be used.
kotarak
It's best if you create your project either using "lein new" or matching the structure you get from it.
technomancy