Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

91 lines (76 sloc) 2.945 kb
(ns leiningen.test.cljsbuild.config
(let [config-0-0-x-early {:source-path "a"
:compiler {:output-to "hello.js"}}
config-0-0-x-late [{:source-path "a"
:compiler {:output-to "hello.js"}}]
config-backwards {:builds
[{:source-path "a"
:compiler {:output-to "hello.js"}}]}]
(backwards-compat config-0-0-x-early) => config-backwards
(backwards-compat config-0-0-x-late) => config-backwards))
(let [config-vec {:builds [{:id "a"} {:id "b"}]}
config-map {:builds {:a {} :b {}}}]
(convert-builds-map config-vec) => config-vec
(convert-builds-map config-map) => config-vec))
(parse-shell-command []) => {:shell []}
(parse-shell-command ["a"]) => {:shell ["a"]}
(parse-shell-command ["a" "b" "c" :x 1 :y 2]) => {:shell ["a" "b" "c"] :x 1 :y 2})
(def config-in
{:repl-launch-commands {:a ["a"]}
:repl-listen-port 10000
:test-commands {:b ["b"]}
:crossover-path "c"
:crossover-jar true
:crossovers ["d" "e"]
'({:source-path "f"
:jar true
:notify-command ["g"]
:incremental false
:assert false
{:output-to "h"
:output-dir "i"
:warnings false
:libs ["j"]
:externs ["k"]
:optimizations :advanced
:pretty-print false}})})
(fact "custom settings are not overwritten by defaults"
(set-default-options config-in) => config-in)
(fact "missing settings have defaults provided"
(doseq [option (keys config-in)]
(set-default-options (dissoc config-in option)) => (contains {option anything})))
(defn- get-build [config]
(first (:builds config)))
(defn- default-build-option [config build option]
(assoc config :builds
(list (dissoc build option)))))
(fact "missing build settings have defaults provided"
(let [build (get-build config-in)]
(doseq [build-option (keys build)]
(let [defaulted (default-build-option config-in build build-option)]
(get-build defaulted) => (contains {build-option anything})))))
(defn- get-compiler [config]
(:compiler (get-build config)))
(defn- default-compiler-option [config compiler option]
(assoc config :builds
(assoc compiler :compiler
(dissoc compiler option))))))
(fact "missing compiler settings have defaults provided"
(let [compiler (:compiler (get-build config-in))]
(doseq [compiler-option (keys compiler)]
(let [defaulted (default-compiler-option config-in compiler compiler-option)]
(get-compiler defaulted) => (contains {compiler-option anything})))))
(def config-out (set-compiler-global-dirs config-in))
(extract-options {:cljsbuild config-in}) => config-out)
Jump to Line
Something went wrong with that request. Please try again.