Skip to content
Browse files

Allow calculated params in defjob (relax args checking)

  • Loading branch information...
1 parent 159f357 commit 7b1c6d6b4d9090754f5a2062db003156f76a8733 @va1en0k va1en0k committed Aug 3, 2013
View
5 src/clojure_hadoop/defjob.clj
@@ -23,9 +23,8 @@
(assoc m k
(cond (keyword? v) (name v)
(number? v) (str v)
- (string? v) v
(symbol? v) (full-name v)
(instance? Boolean v) (str v)
- :else (throw (Exception. "defjob arguments must be strings, symbols, or keywords")))))
+ :else v)))
{} (apply hash-map opts))]
- `(defn ~sym [] ~args)))
+ `(def ~sym (constantly ~args))))
View
2 test/clojure_hadoop/examples/wordcount7.clj
@@ -191,7 +191,7 @@
:output-format :text
:compress-output false
:input "README.txt"
- :output "tmp/out7"
+ :output (str "tmp/out" 7)
:replace true
:add-cache-file files-for-distributed-cache)
View
12 test/clojure_hadoop/test/config.clj
@@ -1,5 +1,8 @@
(ns clojure-hadoop.test.config
- (:use clojure.test clojure-hadoop.config clojure-hadoop.imports))
+ (:use clojure.test
+ clojure-hadoop.config
+ clojure-hadoop.imports
+ clojure-hadoop.defjob))
(import-conf)
(import-fs)
@@ -227,3 +230,10 @@
(deftest test-print-usage
(let [out (with-out-str (print-usage))]
(is (re-find #"Usage.*" out))))
+
+(deftest test-defjob-creates-constant-configs
+ (defjob my-job
+ :timestamp (System/currentTimeMillis))
+ (let [job-conf (my-job)]
+ (Thread/sleep 20)
+ (is (= job-conf (my-job)))))

0 comments on commit 7b1c6d6

Please sign in to comment.
Something went wrong with that request. Please try again.