2

I'm going through clojure & emacs tutorial from clojure-doc.org, and when compiling the test as suggested, i get following output in emacs nrepl:

    clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context, compiling:(/home/jakov/dev/PROJECTS/clojure/test2/test/test2/core_test.clj:1)
             Compiler.java:6281 clojure.lang.Compiler.analyze
             Compiler.java:6223 clojure.lang.Compiler.analyze
             Compiler.java:3497 clojure.lang.Compiler$InvokeExpr.parse
             Compiler.java:6457 clojure.lang.Compiler.analyzeSeq
             Compiler.java:6262 clojure.lang.Compiler.analyze
             Compiler.java:6223 clojure.lang.Compiler.analyze
             Compiler.java:6515 clojure.lang.Compiler.eval
             Compiler.java:6952 clojure.lang.Compiler.load
             Compiler.java:6912 clojure.lang.Compiler.loadFile
                    RT.java:307 clojure.lang.RT$3.invoke
               NO_SOURCE_FILE:1 user/eval42
             Compiler.java:6511 clojure.lang.Compiler.eval
             Compiler.java:6477 clojure.lang.Compiler.eval
                  core.clj:2797 clojure.core/eval
                   main.clj:245 clojure.main/repl[fn]
                   main.clj:266 clojure.main/repl[fn]
                   main.clj:266 clojure.main/repl
               RestFn.java:1096 clojure.lang.RestFn.invoke
      interruptible_eval.clj:56 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
                   AFn.java:159 clojure.lang.AFn.applyToHelper
                   AFn.java:151 clojure.lang.AFn.applyTo
                   core.clj:601 clojure.core/apply
                  core.clj:1771 clojure.core/with-bindings*
                RestFn.java:425 clojure.lang.RestFn.invoke
      interruptible_eval.clj:41 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
     interruptible_eval.clj:171 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
                  core.clj:2278 clojure.core/comp[fn]
     interruptible_eval.clj:138 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
                    AFn.java:24 clojure.lang.AFn.run
    ThreadPoolExecutor.java:895 java.util.concurrent.ThreadPoolExecutor$Worker.runTask
    ThreadPoolExecutor.java:918 java.util.concurrent.ThreadPoolExecutor$Worker.run
                Thread.java:662 java.lang.Thread.run
Caused by: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context
                  Util.java:170 clojure.lang.Util.runtimeException
             Compiler.java:6766 clojure.lang.Compiler.resolveIn
             Compiler.java:6710 clojure.lang.Compiler.resolve
             Compiler.java:6671 clojure.lang.Compiler.analyzeSymbol
             Compiler.java:6244 clojure.lang.Compiler.analyze

To me, it seems like this line is crucial in the nrepl error output:

Caused by: java.lang.RuntimeException: Unable to resolve symbol: deftest in this context

Anyway, i am really a clojure & emacs noob, and I dont have much clue here. All the emacs slime clojure stuff is installed, leiningen2 is installed, java is oracle java 1.6, emacs is emacs 24, and when I run lein test in projects directory, it goes without errors.

Can anyone help me?

EDIT:

My core_test.clj file:

    (deftest pairs-of-values
   (let [args ["--server" "localhost" 
               "--port" "8080" 
               "--environment" "production"]]
      (is (= {:server "localhost"
              :port "8080"
              :environment "production"}
             (parse-args args)))))

My core.clj file:

(defn parse-args [args]
  {})
6
  • 1
    You really should have posted the code that's in your file. Do you have (ns core-test2 (:use clojure.test)) in there? Commented Mar 19, 2013 at 18:58
  • I was following clojure-doc.org tutorial word-for-word.. I edited my question, anyway Commented Mar 19, 2013 at 19:06
  • I started learning clojure like... one day ago :) Commented Mar 19, 2013 at 19:15
  • 2
    The tutorial says "Replace the test that is there with the following". I think you replaced the entire contents of the file, instead of only the (deftest ...) part. So the part that you deleted, but shouldn't have, said (ns command-line-arguments.core-test (:use clojure.test command-line-arguments.core)) Commented Mar 19, 2013 at 19:21
  • Yup. I deleted everything there and put that. I'll try to put that back. Commented Mar 19, 2013 at 19:22

1 Answer 1

3

The tutorial says "Replace the test that is there with the following". I think you replaced the entire contents of the file, instead of only the (deftest ...) part. So the part that you deleted, but shouldn't have, said

(ns test.core-test (:use clojure.test test.core))
Sign up to request clarification or add additional context in comments.

4 Comments

Actually, it was: (ns test.core-test (:use clojure.test test.core)) But, anyway, putting it back solved the issue. That was what leiningen put there by default.
What i got now when I compiled test file was: FileNotFoundException Could not locate test/core__init.class or test/core.clj on classpath: clojure.lang.RT.load (RT.java:432)
Seems like your directory structure is off now. You must have modified it away from what leiningen initially created for you. Do you have src/test/core.clj?
No, thats the point. I even tried it on brand newly created projects: lein new something, turn on emacs, turn on nrepl, open the core_test.clj, try to compile it without any change... and I get this. I tried going to root of the project, doing lein test and lein run in terminal.. It gives me some complaint or the test dont pass, but those are reasonable complaints, different than this. I posted the question separately at stackoverflow.com/posts/comments/21972529?noredirect=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.