aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-02-15 05:51:04 +0000
committerscgilardi <scgilardi@gmail.com>2009-02-15 05:51:04 +0000
commit9d326f54a65e582c0076406cff6204af036fd25d (patch)
tree8b292dc3f8cb182de640cc1df6a97cb22e55f057 /src
parent504ee3b34e60c92adb8e071d71f33c4dc9928894 (diff)
fix issue 17: test compile-path, patch from Shawn Hoover
Diffstat (limited to 'src')
-rw-r--r--src/clojure/contrib/test_clojure.clj1
-rw-r--r--src/clojure/contrib/test_clojure/main.clj40
2 files changed, 41 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_clojure.clj b/src/clojure/contrib/test_clojure.clj
index 8bc921ab..f3217576 100644
--- a/src/clojure/contrib/test_clojure.clj
+++ b/src/clojure/contrib/test_clojure.clj
@@ -26,6 +26,7 @@
:sequences
:for
:agents
+ :main
])
(defn test-name
diff --git a/src/clojure/contrib/test_clojure/main.clj b/src/clojure/contrib/test_clojure/main.clj
new file mode 100644
index 00000000..c3e6f48a
--- /dev/null
+++ b/src/clojure/contrib/test_clojure/main.clj
@@ -0,0 +1,40 @@
+;; Copyright (c) Shawn Hoover. All rights reserved. The use and
+;; distribution terms for this software are covered by the Eclipse Public
+;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can
+;; be found in the file epl-v10.html at the root of this distribution. By
+;; using this software in any fashion, you are agreeing to be bound by the
+;; terms of this license. You must not remove this notice, or any other,
+;; from this software.
+
+(ns clojure.contrib.test-clojure.main
+ (:use clojure.contrib.test-is
+ clojure.main))
+
+(defn- set-properties
+ [settings]
+ (doseq [[name val] settings]
+ (if val
+ (System/setProperty name val)
+ (System/clearProperty name))))
+
+(defmacro with-properties
+ "setting => property-name value
+
+ Sets the system properties to the supplied values, executes the body, and
+ sets the properties back to their original values. Values of nil are
+ translated to a clearing of the property."
+ [settings & body]
+ `(let [settings# ~(apply hash-map settings)
+ current# (map (fn [p#] [p# (System/getProperty p#)])
+ (keys settings#))]
+ (set-properties settings#)
+ (try
+ ~@body
+ (finally
+ (set-properties current#)))))
+
+(deftest compile-path-respects-java-property
+ ;; Bug fixed in r1177; previously was hardwired to the compile-time path.
+ (with-properties ["clojure.compile.path" "compile path test"]
+ (with-bindings
+ (is (= "compile path test" *compile-path*)))))