views:

59

answers:

2

I put Clojure in C:\clojure-1.1.0, and start the REPL by: java -cp clojure.jar clojure.main

In \test\clojure\test_clojure, there are a bunch of test files. How to run these?

For example, I tried: java -cp ......\clojure.jar clojure.main data_structures.clj

And it didn't work.

+2  A: 

Two choices:

  1. Once the REPL starts you can manually load the file with:

    (load-file "\data_structures.clj")

  2. You can pass a command-line option telling it to load/eval a file upon boot:

    java -cp clojure.jar clojure.main -i \data_structures.clj -e "(do-stuff)"

Greg Harman
I tried this:C:\clojure-1.1.0>java -cp clojure.jar clojure.main -i test\clojure\test_clojure\data_structures.clj -e "(do-stuff)"The output is:Exception in thread "main" java.lang.Exception: Unable to resolve symbol: do-stuff in this context (NO_SOURCE_FILE:1) at clojure.lang.Compiler.analyze(Compiler.java:4420) at clojure.lang.Compiler.analyze(Compiler.java:4366) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2828)at clojure.lang.Compiler.analyzeSeq(Compiler.java:4594)at clojure.lang.Compiler.analyze(Compiler.java:4405)...
anta40
Is "do-suff" in the users namespace? If not, you'd need to qualify it or change namespaces.
Greg Harman
A: 

We use (clojure 1.2): java -cp "./target/*-0.1-jar-with-dependencies.jar;src/clojure" jline.ConsoleRunner clojure.main run.clj

I think with tests you can use similar way.

W55tKQbuRu28Q4xv