Tuesday, December 1, 2009

My Clojure Setup - Update

Update: There is now an official Getting Started page for Clojure. Please refer to the instructions on this page for information about how to get started with Clojure in the environment that you are most comfortable with. The information below may now be irrelevant.

I recently posted about my Clojure setup because I thought that it would be useful to others who are getting started with Clojure. I have made a couple of changes to the way I am doing things and thought that it might be time for an update.

The Ruby Script

There have been two changes to the Ruby script that I use to start Clojure. The previous version did not check for command line arguments correctly. This has been fixed. Next, I made a small improvement. I don't like having to type ".clj" each time I run a script so I added some code to add the file extension if you leave it out.

I have included the entire script below.

This isn't meant to be used "as is" on your system. If you plan to use it then you will need to make the necessary modifications to get it working. This is what works for me so I thought I would share.


Running Tests

I have also made improvements to the code that I use to run my tests. See my post on Unit Testing for more information.

I like for my tests to run fast. Clojure makes concurrency easy. Therefore, I have changed my test runner to run each test namespace in parallel. Sometimes I only want to run tests for a single namespace. I can now do this by adding the file name, without the .clj extension as an argument to the script which runs my tests. Finally, if I add "-seq" as a command line argument, all of the test namespaces will be run sequentially.

Here is the code:


This file is part of a small (but growing) set of utilities that I use which can be found on GitHub.

If you are going to run your tests in parallel then they have to be able to run in parallel. It is good practice to set your tests up so that they don't depend on each other. Actually running them in parallel forces you to do this.

I only have two cores on my development machine and this is already saving me time. The more cores that I have in the future the more time it will save. It feels good to know that newer hardware will once again cause my programs to run faster.

0 comments:

Post a Comment